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,54 @@
|
||||
import { redirect } from "next/navigation";
|
||||
import { auth, OIDC_PROVIDER_ID, signIn } from "@/auth";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
const ERRORS: Record<string, string> = {
|
||||
AccessDenied: "Your account is not in a group that is allowed to use this app.",
|
||||
Configuration: "Login is misconfigured. Check the server logs and the OIDC_* settings.",
|
||||
OAuthCallbackError: "The identity provider returned an error. Please try again.",
|
||||
};
|
||||
|
||||
/** Only allow same-origin relative paths as post-login targets. */
|
||||
function safeCallback(value: string | string[] | undefined): string {
|
||||
const v = Array.isArray(value) ? value[0] : value;
|
||||
return v && v.startsWith("/") && !v.startsWith("//") ? v : "/";
|
||||
}
|
||||
|
||||
export default async function LoginPage({ searchParams }: PageProps<"/login">) {
|
||||
const params = await searchParams;
|
||||
const callbackUrl = safeCallback(params.callbackUrl);
|
||||
|
||||
if ((await auth())?.user) redirect(callbackUrl);
|
||||
|
||||
const errorKey = typeof params.error === "string" ? params.error : undefined;
|
||||
const error = errorKey ? (ERRORS[errorKey] ?? "Login failed. Please try again.") : undefined;
|
||||
|
||||
return (
|
||||
<main className="flex min-h-screen items-center justify-center p-4">
|
||||
<Card className="w-full max-w-sm">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Model Manager</CardTitle>
|
||||
<CardDescription>Sign in to manage local models.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-3">
|
||||
{error && (
|
||||
<p role="alert" className="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
<form
|
||||
action={async () => {
|
||||
"use server";
|
||||
await signIn(OIDC_PROVIDER_ID, { redirectTo: callbackUrl });
|
||||
}}
|
||||
>
|
||||
<Button type="submit" className="w-full" size="lg">
|
||||
Sign in with Pocket ID
|
||||
</Button>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user