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:
commit
891e496157
47 files changed
+14945
No files matched your search
@@ -0,0 +1,15 @@
|
||||
import "server-only";
|
||||
import type { Session } from "next-auth";
|
||||
import { NextResponse } from "next/server";
|
||||
import { auth } from "@/auth";
|
||||
|
||||
type Handler<Ctx> = (req: Request, ctx: Ctx & { session: Session }) => Promise<Response> | Response;
|
||||
|
||||
/** Wraps a route handler so it only runs for a logged-in user (defense in depth behind proxy.ts). */
|
||||
export function withAuth<Ctx = unknown>(handler: Handler<Ctx>) {
|
||||
return async (req: Request, ctx: Ctx) => {
|
||||
const session = await auth();
|
||||
if (!session?.user) return NextResponse.json({ error: "unauthorized" }, { status: 401 });
|
||||
return handler(req, { ...ctx, session });
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user