pagepublishedmdai-assisted

Admin UI + Passkey Auth Plan

Building a local admin interface with passwordless WebAuthn authentication using Bitwarden's passwordless.dev service.

Path
/notes/admin-ui-passkey-auth-plan
Published
Mar 30, 2026
Revised
—
Project
jaygriff-v3
Tags

On this page

Stored toc, derived from the body's headings on save. The body below isn't rendered yet, so these show the anchor ids rather than linking to them.

  • Why passwordless.dev #why-passwordlessdev
  • Auth Stack #auth-stack
  • Flow #flow
  • One-time registration (localhost only) #one-time-registration-localhost-only
  • Sign in #sign-in
  • Sign out #sign-out
  • Routes #routes
  • Admin UI #admin-ui
  • Security Notes #security-notes
  • Implementation Order #implementation-order

Body

markdownbody.md
# Admin UI + Passkey Auth Plan

The goal: a local admin interface for managing site content (editing titles, descriptions, tags, publishing/unpublishing) — protected by a passkey via passwordless.dev (Bitwarden's WebAuthn service).

## Why passwordless.dev

- Bitwarden-backed, free up to 10k users, trustworthy
- Handles the WebAuthn ceremony so we never touch `navigator.credentials` directly
- Passkeys are stored in Bitwarden - same workflow as everything else
- Right-sized for a personal site: no Clerk overhead, no OAuth dance, no passwords to manage

## Auth Stack

- **passwordless.dev** — WebAuthn registration + assertion
- **`@passwordlessdev/passwordless-client`** — browser-side SDK (triggers passkey prompt)
- **`jose`** — sign and verify a JWT stored in an `httpOnly` cookie
- **Next.js middleware** — protect all `/admin/*` routes at the edge

## Flow

### One-time registration (localhost only)

1. Hit `/admin/register` (disabled in production)
2. Server calls passwordless.dev API → gets a registration token
3. Client SDK uses that token to trigger the browser passkey creation prompt
4. Passkey saved in Bitwarden
5. Done — never do this again

### Sign in

1. Hit `/admin/login`
2. Client SDK triggers passkey assertion (Bitwarden prompt)
3. Server verifies the assertion token with passwordless.dev API
4. Server signs a JWT (`jose`) and sets it as an `httpOnly` `Secure` cookie
5. Middleware reads cookie on every `/admin/*` request — valid JWT = through, missing/invalid = redirect to `/admin/login`

### Sign out

Delete the session cookie.

## Routes

```
/admin                    → redirect to /admin/content
/admin/login              → passkey sign-in page (client component)
/admin/register           → one-time passkey registration (disabled in prod)
/admin/content            → list all content rows (draft + published + archived)
/admin/content/[slug]     → edit title, description, type, status, tags, etc.
```

## Admin UI

The content editor at `/admin/content/[slug]` needs to update fields in Turso directly — no sync script, no file changes. Fields editable from the UI:

- `title`
- `description`
- `status` (draft → published → archived)
- `tags`
- `type`
- `thumbnail`
- `feature`
- `authorship_note`

Save triggers a Server Action that runs an UPDATE query against Turso. No page reload required.

## Security Notes

- Registration route disabled (404) when `NODE_ENV === "production"`
- Session JWT signed with a secret from env (`ADMIN_JWT_SECRET`) — rotate to invalidate all sessions
- Cookie is `httpOnly`, `Secure`, `SameSite=Lax`
- Middleware runs at the edge — unauthenticated requests never reach page code

## Implementation Order

1. Install `@passwordlessdev/passwordless-client` and `jose`
2. Add env vars: `PASSWORDLESS_API_KEY`, `PASSWORDLESS_API_SECRET`, `ADMIN_JWT_SECRET`
3. Build `/admin/login` (client component, calls SDK)
4. Build Route Handlers: `/api/auth/signin/token`, `/api/auth/signin/verify`, `/api/auth/signout`
5. Build middleware for `/admin/*`
6. Build registration flow (localhost only)
7. Build `/admin/content` listing page
8. Build `/admin/content/[slug]` editor with Server Action save

Raw row

jsonadmin-ui-passkey-auth-plan.json
{
  "id": "78b77739-1663-4ba3-9d92-99d3b4b00926",
  "parentId": "b455ec91-16d1-41f1-a222-a7097ea66c25",
  "slug": "admin-ui-passkey-auth-plan",
  "path": "/notes/admin-ui-passkey-auth-plan",
  "type": "page",
  "status": "published",
  "title": "Admin UI + Passkey Auth Plan",
  "description": "Building a local admin interface with passwordless WebAuthn authentication using Bitwarden's passwordless.dev service.",
  "intro": null,
  "body": "# Admin UI + Passkey Auth Plan\n\nThe goal: a local admin interface for managing site content (editing titles, descriptions, tags, publishing/unpublishing) — protected by a passkey via passwordless.dev (Bitwarden's WebAuthn service).\n\n## Why passwordless.dev\n\n- Bitwarden-backed, free up to 10k users, trustworthy\n- Handles the WebAuthn ceremony so we never touch `navigator.credentials` directly\n- Passkeys are stored in Bitwarden - same workflow as everything else\n- Right-sized for a personal site: no Clerk overhead, no OAuth dance, no passwords to manage\n\n## Auth Stack\n\n- **passwordless.dev** — WebAuthn registration + assertion\n- **`@passwordlessdev/passwordless-client`** — browser-side SDK (triggers passkey prompt)\n- **`jose`** — sign and verify a JWT stored in an `httpOnly` cookie\n- **Next.js middleware** — protect all `/admin/*` routes at the edge\n\n## Flow\n\n### One-time registration (localhost only)\n\n1. Hit `/admin/register` (disabled in production)\n2. Server calls passwordless.dev API → gets a registration token\n3. Client SDK uses that token to trigger the browser passkey creation prompt\n4. Passkey saved in Bitwarden\n5. Done — never do this again\n\n### Sign in\n\n1. Hit `/admin/login`\n2. Client SDK triggers passkey assertion (Bitwarden prompt)\n3. Server verifies the assertion token with passwordless.dev API\n4. Server signs a JWT (`jose`) and sets it as an `httpOnly` `Secure` cookie\n5. Middleware reads cookie on every `/admin/*` request — valid JWT = through, missing/invalid = redirect to `/admin/login`\n\n### Sign out\n\nDelete the session cookie.\n\n## Routes\n\n```\n/admin                    → redirect to /admin/content\n/admin/login              → passkey sign-in page (client component)\n/admin/register           → one-time passkey registration (disabled in prod)\n/admin/content            → list all content rows (draft + published + archived)\n/admin/content/[slug]     → edit title, description, type, status, tags, etc.\n```\n\n## Admin UI\n\nThe content editor at `/admin/content/[slug]` needs to update fields in Turso directly — no sync script, no file changes. Fields editable from the UI:\n\n- `title`\n- `description`\n- `status` (draft → published → archived)\n- `tags`\n- `type`\n- `thumbnail`\n- `feature`\n- `authorship_note`\n\nSave triggers a Server Action that runs an UPDATE query against Turso. No page reload required.\n\n## Security Notes\n\n- Registration route disabled (404) when `NODE_ENV === \"production\"`\n- Session JWT signed with a secret from env (`ADMIN_JWT_SECRET`) — rotate to invalidate all sessions\n- Cookie is `httpOnly`, `Secure`, `SameSite=Lax`\n- Middleware runs at the edge — unauthenticated requests never reach page code\n\n## Implementation Order\n\n1. Install `@passwordlessdev/passwordless-client` and `jose`\n2. Add env vars: `PASSWORDLESS_API_KEY`, `PASSWORDLESS_API_SECRET`, `ADMIN_JWT_SECRET`\n3. Build `/admin/login` (client component, calls SDK)\n4. Build Route Handlers: `/api/auth/signin/token`, `/api/auth/signin/verify`, `/api/auth/signout`\n5. Build middleware for `/admin/*`\n6. Build registration flow (localhost only)\n7. Build `/admin/content` listing page\n8. Build `/admin/content/[slug]` editor with Server Action save\n",
  "toc": [
    {
      "depth": 2,
      "text": "Why passwordless.dev",
      "id": "why-passwordlessdev"
    },
    {
      "depth": 2,
      "text": "Auth Stack",
      "id": "auth-stack"
    },
    {
      "depth": 2,
      "text": "Flow",
      "id": "flow"
    },
    {
      "depth": 3,
      "text": "One-time registration (localhost only)",
      "id": "one-time-registration-localhost-only"
    },
    {
      "depth": 3,
      "text": "Sign in",
      "id": "sign-in"
    },
    {
      "depth": 3,
      "text": "Sign out",
      "id": "sign-out"
    },
    {
      "depth": 2,
      "text": "Routes",
      "id": "routes"
    },
    {
      "depth": 2,
      "text": "Admin UI",
      "id": "admin-ui"
    },
    {
      "depth": 2,
      "text": "Security Notes",
      "id": "security-notes"
    },
    {
      "depth": 2,
      "text": "Implementation Order",
      "id": "implementation-order"
    }
  ],
  "format": "md",
  "componentKey": null,
  "contentHash": null,
  "authors": null,
  "authorship": "ai-assisted",
  "authorshipNote": null,
  "tags": [
    "webauthn",
    "passkeys",
    "authentication",
    "admin",
    "nextjs",
    "passwordless",
    "bitwarden",
    "security"
  ],
  "projectId": "b3d6e577-4481-4477-9b9f-cea025e63e92",
  "sectionId": "0d49a226-e6de-4867-870b-2a600dbf618e",
  "publishedAt": "2026-03-30T05:10:20.187Z",
  "revisedAt": null,
  "sortOrder": 0,
  "source": "db",
  "file": null,
  "missingSince": null,
  "createdAt": "2026-11-18T21:23:54.391Z",
  "updatedAt": "2026-12-01T03:56:05.437Z",
  "link": null,
  "project": {
    "slug": "jaygriff-v3",
    "title": "jaygriff-v3",
    "status": "published"
  },
  "section": {
    "slug": "roadmap",
    "title": "Roadmap"
  },
  "assets": []
}