Repository navigation
feat: add user authentication and React frontend - #24
Merged
Merged
Conversation
Backend: - Add users table and kv table to SQLite schema with migration - Implement JWT auth (bcrypt password hashing, token issue/verify) - Add /auth/register, /auth/login, /auth/me API endpoints - Add CORS middleware for frontend separation - Add pyjwt and bcrypt dependencies Frontend (web/): - Initialize Vite + React + TypeScript project - Add Ant Design UI and React Router - Implement Login, Register pages with form validation - Implement Dashboard page with project list table - Add AuthGuard route protection component - Add API client with auto JWT attachment and 401 redirect - Configure Vite proxy for development API forwarding
- Add require_auth dependency to all routers (projects, intents, hints, export, settings) - Support dual auth: JWT (frontend users) and API Key (dispatcher) - Add server_token field to DispatchConfig for dispatcher authentication - CairnClient sends X-API-Key header when server_token is configured - Update dispatch.example.yaml with server_token field - Update docker-compose.yaml with CAIRN_API_KEYS environment variable - Fix healthcheck endpoint to use /openapi.json (auth-free) - Update tests to use API Key authentication
21 tests covering: - Registration: success, duplicate username, validation errors - Login: valid credentials, wrong password, nonexistent user - JWT: /auth/me with valid/invalid/missing token - API Key: correct key grants access, wrong key rejected - Protected routes: 401 without auth on projects/settings/hints - JWT on protected routes: projects and settings accessible - Auth-free endpoints: register, login, openapi.json - Full flow: register -> login -> me -> create project -> export
…eact # Conflicts: # cairn/src/cairn/server/routers/export.py # cairn/uv.lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
web/projectBackend changes
cairn/server/auth.py— JWT token management, password hashing,get_current_userdependencycairn/server/routers/auth.py—POST /auth/register,POST /auth/login,GET /auth/mecairn/server/db.py—usersandkvtables with migration for existing databasescairn/server/app.py— CORS middleware + auth router registrationpyjwt,bcryptFrontend (
web/)Architecture note
Existing internal APIs (
/projects,/intents, etc.) remain unauthenticated — the Dispatcher communicates via these endpoints within the Docker network. Full API authentication is deferred to the v1.0 gRPC rewrite.Test plan