Files
llmapikey/components/site-header.js
T
tiennm99 559bac8104 feat(auth): replace Supabase Auth with app-native GitHub OAuth
Self-contained GitHub OAuth (Arctic) with a stateless HS256 signed-cookie
session (jose); Supabase is downgraded to the Postgres host only.

- Origin-derived callback (no redirect-uri env); read:user scope; access
  token read once at callback and discarded (no token storage).
- CSRF via single-use state cookie; open-redirect guard on next.
- getCurrentGithubIdentity() now reads the session cookie, preserving the
  numeric provider_id identity contract for admin/dashboard/mint.
- Remove @supabase/ssr + @supabase/supabase-js, middleware, and the
  supabase-dependent rls test; delete lib/supabase clients.
2026-06-14 12:19:40 +07:00

40 lines
1.1 KiB
JavaScript

import Link from "next/link";
import { getCurrentGithubIdentity } from "@/lib/auth/current-github-identity";
/**
* Session-aware header (server component). Shows Dashboard + sign-out when
* authenticated; just Docs otherwise. Display only — the login is fine here.
*/
export async function SiteHeader() {
let username = null;
try {
const identity = await getCurrentGithubIdentity();
username = identity?.githubUsername ?? null;
} catch {
username = null; // auth not configured (no secret) — render signed-out header
}
return (
<header className="site-header">
<Link href="/" className="brand">
llmapikey
</Link>
<nav className="site-nav">
<Link href="/docs">Docs</Link>
{username ? (
<>
<Link href="/dashboard">Dashboard</Link>
<span className="muted">@{username}</span>
<form action="/auth/sign-out" method="post">
<button className="btn secondary" type="submit">
Sign out
</button>
</form>
</>
) : null}
</nav>
</header>
);
}