fix: SSO login redirects back to login page after successful auth (v2)#13446
Open
liuxiaoyusky wants to merge 1 commit intoinfiniflow:mainfrom
Open
fix: SSO login redirects back to login page after successful auth (v2)#13446liuxiaoyusky wants to merge 1 commit intoinfiniflow:mainfrom
liuxiaoyusky wants to merge 1 commit intoinfiniflow:mainfrom
Conversation
Two independent root causes: 1. Backend `_load_user()` fails JWT verification when frontend sends `Authorization: Bearer <token>` — the Bearer prefix is included in the signature check, causing a mismatch. Fix: strip "Bearer " prefix before JWT deserialization. 2. After route loader stores the token and redirects (removing ?auth= from URL), child components render immediately and fire API requests before auth state is confirmed. The empty/stale Authorization header triggers 401, which the Axios interceptor handles by clearing localStorage and redirecting to /login. Fix: add auth guard in NextLayout using useAuth() to block rendering until login status is confirmed. Made-with: Cursor
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
Clean re-submission of #13371 with only the SSO fix (13 lines, 2 files).
Root Causes:
Backend:
_load_user()fails JWT verification when frontend sendsAuthorization: Bearer <token>— the Bearer prefix is included in the signature check, causing mismatch.Frontend: Child components render and fire API requests before auth state is confirmed, triggering 401 → localStorage clear → redirect loop.
Fix:
api/apps/__init__.py)NextLayoutusinguseAuth()to block rendering until login status confirmed (web/src/layouts/next.tsx)Changes
Risk Analysis
?jwt_auth=)Test Plan
curlwith bothAuthorization: <token>andAuthorization: Bearer <token>returnscode=0?jwt_auth=) still worksWhy v2?
PR #13371 was closed due to:
This PR contains only the SSO fix, making it review-friendly.
Made with ❤️ and proper git hygiene