Milestone (a): project skeleton and OIDC login

- Next.js 16 + Tailwind + shadcn/ui skeleton
- Auth.js v5 generic OIDC (Pocket ID, PKCE) with optional group gate
- proxy.ts gates all pages and API routes
- Drizzle schema (models, files, jobs, logs, worker state) on SQLite/libsql
- Worker skeleton: migrations, interrupted-job recovery, heartbeat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal LinxweilerandClaude Opus 5.5 committed 2026-10-05 15:32:52 +02:00
commit 891e496157
47 files changed
+14945

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import { type NextFetchEvent, type NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
// Gate every page and API route. Unauthenticated page requests go to /login,
// API requests get a 401. Route handlers check the session again (see lib/api-auth.ts).
const gate = auth((req) => {
if (req.auth) return;
const { pathname, search } = req.nextUrl;
if (pathname.startsWith("/api/")) {
return NextResponse.json({ error: "unauthorized" }, { status: 401 });
}
const loginUrl = new URL("/login", req.url);
if (pathname !== "/") loginUrl.searchParams.set("callbackUrl", pathname + search);
return NextResponse.redirect(loginUrl);
});
// Next.js requires a literal function export here; `export default auth(...)` isn't recognized.
// With a lazy (function) config, next-auth's `auth(handler)` returns a Promise of the handler,
// even though its types say otherwise, hence the await.
type ProxyHandler = (req: NextRequest, event: NextFetchEvent) => Promise<Response | undefined>;
export async function proxy(req: NextRequest, event: NextFetchEvent) {
const handler = (await gate) as unknown as ProxyHandler;
return handler(req, event);
}
export const config = {
// Everything except the Auth.js endpoints, the login page and static assets.
matcher: ["/((?!api/auth|login|_next/static|_next/image|favicon.ico).*)"],
};