Personal Access Tokens for non-browser clients #49
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol#49
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add a per-user, revocable token primitive so external agent runtimes (Claude Code, opencode, custom MCP clients) can authenticate to Carol without holding a session cookie.
Carol's current auth (ADR-0004) is server-side opaque sessions, browser-cookie only. That works perfectly for the PWA but doesn't translate to a CLI / desktop / headless client. A PAT system slots in alongside sessions: the auth middleware authorises a request whose
Authorization: Bearer <token>header carries a valid PAT exactly as it would a valid session cookie, with the same per-user data isolation downstream.Scope
personal_access_tokenstable:(id, user_id, token_hash, name, scopes, created_at, last_used_at, expires_at, revoked_at). Tokens are server-generated, returned to the user exactly once at creation, and stored hashed (argon2id, the same primitive we use for passwords).Authorization: Bearer <token>, look up by hashed token; on hit, populate the request user the same way a session cookie does. Session cookies remain the only auth for browser routes; PATs are rejected there. PATs only authenticate API endpoints.agentscope. The shape supports adding scopes later without a schema change.Acceptance criteria
personal_access_tokenstable migration applies on startup, both engines.Authorization: Bearer <token>reaches authorised endpoints as that user; the same request with the token revoked returns 401.Part of epic #47. Builds on ADR-0004 (server-side sessions).