Repository navigation
Oauth refactor - #505
Merged
Merged
Oauth refactor#505
Conversation
- Replace hardcoded provider routes with unified wildcard endpoint - Implement generic OAuth methods using OAuthProvidersSchema - Add comprehensive error handling for unsupported providers - Remove repetitive code and improve maintainability - Fix route ordering to prevent wildcard route conflicts - Enhance type safety across frontend and backend - Add dynamic provider management in frontend - Remove noisy else statements for cleaner code"
feat: refactor OAuth system for scalability and type safety
tonychang04
marked this pull request as ready for review
October 22, 2025 18:56
Contributor
|
Caution Review failedThe pull request is closed. WalkthroughConsolidates provider-specific OAuth flows into a provider-agnostic flow with signed JWT state, origin validation via OAUTH_ALLOWED_ORIGINS/DEFAULT_FRONTEND_ORIGIN, secure httpOnly cookie delivery of tokens, schema/type updates to use OAuthProvidersSchema, and expanded OAuth config fields (id, createdAt, updatedAt). Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
participant AuthService
participant Provider as "OAuth Provider"
User->>Frontend: Click "Connect [Provider]"
Frontend->>Backend: GET /api/auth/oauth/:provider?origin=...
Backend->>Backend: validateRedirectOrigin(origin)
Backend->>Backend: sign state JWT (includes origin)
Backend->>AuthService: generateAuthUrl(provider, state)
AuthService-->>Backend: return provider auth URL
Backend->>Provider: Redirect user to provider auth URL
Provider->>Backend: Callback to /api/auth/oauth/shared/callback/:state (code/token)
Backend->>Backend: verify JWT state → extract origin
Backend->>AuthService: handleOAuthCallback(provider, payload)
AuthService-->>Backend: CreateSessionResponse (user,tokens)
Backend->>Backend: set secure httpOnly cookie (access_token)
Backend->>Frontend: Redirect to extracted origin (no token in URL)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (13)
Comment |
Merged
This was referenced Oct 23, 2025
This was referenced Nov 2, 2025
Merged
This was referenced Nov 11, 2025
This was referenced Dec 9, 2025
Closed
Merged
Merged
This was referenced Jan 16, 2026
This was referenced Mar 14, 2026
Merged
This was referenced Mar 21, 2026
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
How did you test this change?
Summary by CodeRabbit
New Features
Configuration
OAUTH_ALLOWED_ORIGINSandDEFAULT_FRONTEND_ORIGIN