# Passkey Authentication Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Replace repeated Basic Auth prompts on `dzen.nstarikov.ru` with VK ID for the allowlisted VK user and Face ID, Touch ID, Windows Hello, or another WebAuthn passkey. **Architecture:** FastAPI will own authentication for `/admin` and `/api`: VK ID bootstrap is restricted to `vk_user_id=32018`, WebAuthn challenge endpoints issue registration and authentication options, verification creates an HttpOnly session cookie, and middleware protects all other admin/API routes. SQLite stores passkey credentials and sessions. Caddy no longer applies Basic Auth to the main host. **Tech Stack:** FastAPI, SQLAlchemy/SQLite, `webauthn` Python package, browser WebAuthn API, React/Vite, Caddy. --- ### Task 1: Persist passkeys and sessions **Files:** - Modify: `requirements.txt` - Modify: `app/models.py` - Modify: `app/database.py` - Modify: `app/config.py` - [ ] Add `webauthn==3.0.0`, passkey credential/session models, and migration columns/tables. - [ ] Add RP ID, RP name, session lifetime, and one-time bootstrap settings. - [ ] Verify imports and SQLite table creation in the container. ### Task 2: Add FastAPI WebAuthn flows and protection **Files:** - Create: `app/auth.py` - Modify: `app/main.py` - Modify: `app/routes.py` - [ ] Add registration options/verification and authentication options/verification using `generate_*_options`, `verify_*_response`, and JSON helpers from `webauthn`. - [ ] Set and clear Secure, HttpOnly, SameSite=Lax session cookies. - [ ] Permit only auth bootstrap/challenge/verify/health without a session; require a session for `/admin`, `/api`, and logs WebSockets. - [ ] Keep first-device registration guarded by an authenticated VK ID session. ### Task 3: Add passkey UI **Files:** - Modify: `admin/src/App.tsx` - Modify: `admin/src/index.css` - [ ] Show a compact login screen when the API returns `401`. - [ ] Add «Войти по Face ID / Touch ID» and «Зарегистрировать это устройство» actions using `navigator.credentials`. - [ ] Add logout and clear error states; preserve the existing dashboard after session restoration. - [ ] Keep the UI usable in standalone iPhone PWA and desktop browsers. ### Task 4: Update Caddy and verify migration **Files:** - Modify: `Caddyfile.server` - Modify: `Caddyfile.snippet` if needed - [ ] Remove Basic Auth from the main `dzen.nstarikov.ru` route. - [ ] Validate Caddy configuration, deploy API/admin/Caddy changes, and verify HTTPS origin and cookie behavior. - [ ] Test registration and login on iPhone Safari/PWA and a desktop platform authenticator. ### Task 5: Regression checks - [ ] Run `python3 -m py_compile app/*.py` and `npm --prefix admin run build`. - [ ] Verify unauthenticated API returns `401`, authenticated API returns `200`, `/feed` remains public, and WebSocket logs accept the session cookie. - [ ] Verify the VK allowlist and passkey session boundary; no Basic Auth fallback remains on the main host.