feat(server): add OAuth device flow for Google authentication#15
Merged
Conversation
Implements RFC 8628 (OAuth 2.0 Device Authorization Grant) for Google OAuth. Device flow endpoints: - POST /api/v1/auth/device/code - CLI initiates device authorization - POST /api/v1/auth/device/token - CLI polls for session token - GET /api/v1/auth/device/verify - User enters code (HTML form) - POST /api/v1/auth/device/verify - User submits code, redirects to Google - GET /api/v1/auth/callback/:provider - OAuth callback, creates session Features: - In-memory device state with automatic expiration (15 min) - User-friendly 8-char codes (XXXX-XXXX format) - Rate limiting for token polling (5s minimum interval) - CSRF protection via OAuth state parameter - Clean HTML pages for code entry and success/error Files added: - auth/types.ts - Device flow and OAuth types - auth/device-flow.ts - State management (21 unit tests) - auth/providers/google.ts - Google OAuth config - auth/providers/index.ts - Provider registry - handlers/auth.ts - HTTP request handlers Updated router.ts to wire up specific auth routes instead of wildcard. Updated tests to reflect new implementation. 234 tests passing.
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
Implements OAuth device flow (RFC 8628) for Google authentication (Chunk 7 of server implementation).
Changes
New Files
packages/server/auth/types.ts- Device flow and OAuth typespackages/server/auth/device-flow.ts- In-memory device state managementpackages/server/auth/device-flow.test.ts- 21 unit tests for state managementpackages/server/auth/providers/google.ts- Google OAuth configurationpackages/server/auth/providers/index.ts- Provider registrypackages/server/auth/index.ts- Module exportspackages/server/handlers/auth.ts- HTTP request handlersEndpoints Implemented
/api/v1/auth/device/code/api/v1/auth/device/token/api/v1/auth/device/verify/api/v1/auth/device/verify/api/v1/auth/callback/:providerDevice Flow
Features
Environment Variables Required
Test Results
Next Chunks
feature/server-oauth-github)feature/server-rate-limit)