feat: OAuth 2.0 authorization server for Flutter app#2308
Draft
feat: OAuth 2.0 authorization server for Flutter app#2308
Conversation
The refresh token cookie was path-scoped to /api/v1/user/token/refresh, which prevented it from being sent on requests to /api/v1/oauth/authorize. This broke the browser-based OAuth flow: after login, when Login.vue redirects to the authorize endpoint via window.location.href, the server could not detect the user's session because the cookie wasn't included. Widen the path to /api/v1/ so the cookie is sent on all API requests. The cookie remains HttpOnly and SameSite=Strict, so the security posture is unchanged.
Covers the full browser flow that backend tests cannot exercise: unauthenticated user → login redirect → login via UI → Login.vue reads the redirect query param and navigates back to the authorize endpoint → authorization code issued → token exchange. Uses page.route() to proxy the authorize request from the frontend origin to the real API server with the JWT, since the E2E test runs the API and frontend on separate ports (in production they share an origin).
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
This PR implements an OAuth 2.0 authorization server to enable the Flutter app to authenticate using the authorization code flow with PKCE.
Changes
Backend
Frontend
Tests
OAuth Flow
Security Features