Author SHA1 Message Date
Cursor Agent 88c0c4a453 Fix Authelia OIDC state check and hide redirect URI on login
Auth.js OIDC defaults to PKCE-only, so no `state` was sent; Authelia
rejects that. Enable checks: pkce + state. Remove the public redirect
URI hint from the login page.
2026-08-24 04:12:34 +00:00
Nick TrochalakisandCursor Agent 443dba5bba Publish Docker image to GHCR on each main build (#8)
Add a Docker workflow that builds on PRs and pushes to
ghcr.io/chewbaccalakis/rfid-database on main (latest + sha) and v* tags.
Drop the redundant docker-build job from CI.

Co-authored-by: Cursor Agent <[email protected]>
2026-08-24 04:10:58 +00:00
Nick Trochalakis 3bcdc14106 Merge pull request #7 from Chewbaccalakis/cursor/fix-login-dynamic-oidc-e593
Fix OIDC button: force dynamic /login (was prerendered at build)
2026-08-23 21:05:12 -07:00
Cursor Agent f2de0e3892 Fix missing OIDC button: stop static-prerendering /login
/login was prerendered at Docker build time when AUTH_OIDC_* were
unset, baking oidcEnabled=false into the page. Force dynamic render
and also read /api/v1/auth/config on the client as a fallback.
2026-08-24 04:02:37 +00:00
Nick TrochalakisandCursor Agent cd1a2fe808 Harden OIDC + auth config diagnostics endpoint (#6)
Request openid email profile, use client_secret_post, surface OIDC
errors on /login, and expose a no-auth diagnostics endpoint so operators
can verify the running container sees AUTH_OIDC_* and the callback URL.

Co-authored-by: Cursor Agent <[email protected]>
2026-08-24 03:57:29 +00:00
7 changed files with 119 additions and 34 deletions
-8
View File
@@ -22,11 +22,3 @@ jobs:
- run: npm run build
env:
AUTH_SECRET: ci-build-secret-at-least-32-characters
docker:
name: docker-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build production image
run: docker build -t rfid-database:ci .
+60
View File
@@ -0,0 +1,60 @@
name: Docker
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
env:
REGISTRY: ghcr.io
# GHCR requires lowercase image names
IMAGE_NAME: ghcr.io/chewbaccalakis/rfid-database
jobs:
build-and-push:
name: build-and-push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-,format=short
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
+18 -2
View File
@@ -117,10 +117,26 @@ npm run typecheck
npm run build
```
GitHub Actions runs on every pull request and push to `main`:
GitHub Actions on every pull request and push to `main`:
1. **lint / typecheck / test / Next.js build**
2. **`docker build`** — catches Dockerfile parse/build failures (the class of break that conflict markers previously caused)
2. **Docker image** — build on PRs; on `main` (and `v*` tags) push to GHCR:
`ghcr.io/chewbaccalakis/rfid-database`
### Pull the published image
```bash
docker pull ghcr.io/chewbaccalakis/rfid-database:latest
# or a specific commit: ghcr.io/chewbaccalakis/rfid-database:sha-<shortsha>
```
If the package is private, authenticate first:
```bash
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
```
Or in Compose, set `image: ghcr.io/chewbaccalakis/rfid-database:latest` and comment out `build:`.
## Docker
+4
View File
@@ -1,9 +1,13 @@
services:
rfid-database:
# Local build (default):
build:
context: .
dockerfile: Dockerfile
image: rfid-database:local
# Or pull from GHCR instead of building:
# image: ghcr.io/chewbaccalakis/rfid-database:latest
# pull_policy: always
container_name: rfid-database
restart: unless-stopped
ports:
+4 -6
View File
@@ -1,17 +1,15 @@
import { isOidcConfigured } from "@/lib/auth/oidc";
import { LoginPageClient } from "@/components/LoginPageClient";
export default function LoginPage() {
const authUrl = (process.env.AUTH_URL || "").replace(/\/$/, "");
const callbackUrlHint = authUrl
? `${authUrl}/api/auth/callback/oidc`
: "https://<your-host>/api/auth/callback/oidc";
// OIDC env is only available at runtime (Docker). Never prerender this page
// at build time or the SSO button stays permanently hidden.
export const dynamic = "force-dynamic";
export default function LoginPage() {
return (
<LoginPageClient
oidcEnabled={isOidcConfigured()}
oidcName={process.env.AUTH_OIDC_NAME || "SSO"}
callbackUrlHint={callbackUrlHint}
/>
);
}
+25 -12
View File
@@ -1,6 +1,6 @@
"use client";
import { FormEvent, useState } from "react";
import { FormEvent, useEffect, useState } from "react";
import { signIn } from "next-auth/react";
import { useRouter, useSearchParams } from "next/navigation";
import { Suspense } from "react";
@@ -8,7 +8,11 @@ import { Suspense } from "react";
type Props = {
oidcEnabled: boolean;
oidcName: string;
callbackUrlHint: string;
};
type AuthConfig = {
oidcEnabled: boolean;
oidcName: string;
};
function authErrorMessage(code: string | null): string | null {
@@ -30,7 +34,7 @@ function authErrorMessage(code: string | null): string | null {
}
}
function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
function LoginForm({ oidcEnabled, oidcName }: Props) {
const router = useRouter();
const params = useSearchParams();
const callbackUrl = params.get("callbackUrl") || "/";
@@ -40,6 +44,22 @@ function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
authErrorMessage(params.get("error"))
);
const [loading, setLoading] = useState(false);
const [runtimeOidc, setRuntimeOidc] = useState<AuthConfig | null>(null);
// Belt-and-suspenders: ask the live API so a stale static shell can't hide SSO
useEffect(() => {
fetch("/api/v1/auth/config")
.then((r) => (r.ok ? r.json() : null))
.then((data: AuthConfig | null) => {
if (data) setRuntimeOidc(data);
})
.catch(() => {
/* ignore */
});
}, []);
const showOidc = runtimeOidc?.oidcEnabled ?? oidcEnabled;
const displayName = runtimeOidc?.oidcName || oidcName;
async function onSubmit(e: FormEvent) {
e.preventDefault();
@@ -97,21 +117,14 @@ function LoginForm({ oidcEnabled, oidcName, callbackUrlHint }: Props) {
<button className="btn" type="submit" disabled={loading}>
{loading ? "Signing in…" : "Sign in"}
</button>
{oidcEnabled && (
<>
{showOidc && (
<button
type="button"
className="btn btn-secondary"
onClick={() => signIn("oidc", { callbackUrl })}
>
Sign in with {oidcName}
Sign in with {displayName}
</button>
<p className="muted" style={{ margin: 0, fontSize: "0.75rem" }}>
IdP redirect URI must be exactly:
<br />
<code className="mono">{callbackUrlHint}</code>
</p>
</>
)}
</form>
</div>
+2
View File
@@ -45,6 +45,8 @@ function buildProviders(): Provider[] {
wellKnown: `${issuer}/.well-known/openid-configuration`,
clientId: process.env.AUTH_OIDC_CLIENT_ID!,
clientSecret: process.env.AUTH_OIDC_CLIENT_SECRET!,
// Auth.js OIDC defaults to PKCE-only; Authelia requires a strong `state`
checks: ["pkce", "state"],
authorization: {
params: {
scope: "openid email profile",