fix: reset abandoned code flow flag on non-callback checkAuth (#2221)#2224
Open
FabianGosebrink wants to merge 1 commit into
Open
fix: reset abandoned code flow flag on non-callback checkAuth (#2221)#2224FabianGosebrink wants to merge 1 commit into
FabianGosebrink wants to merge 1 commit into
Conversation
When a code flow is started via authorize() but abandoned (the user returns to the app without the authorization callback URL), storageCodeFlowInProgress was left true permanently, because resetCodeFlowInProgress is only called from the code-flow callback path. If the session is then established via checkAuthIncludingServer -> forceRefreshSession (iframe silent renew), shouldStartPeriodicallyCheckForConfig keeps returning false, so tokens are never silently renewed. Reset the flag in checkAuthWithConfig whenever the current URL is not a callback: there is no in-flight code flow to protect in that case. Fixes #2221 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
|
I would need to verify that this has no side effects |
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
Fixes #2221 — the
storageCodeFlowInProgressflag was never reset when a code flow is abandoned and the session is later established via silent renew, permanently disabling periodic token renewal.Root cause
resetCodeFlowInProgressis only called inCodeFlowCallbackService.authenticatedCallbackWithCode, which is reached only when the current URL contains an authorization code (isCallback === true).When a user calls
authorize()(which setsstorageCodeFlowInProgress = true), authenticates at the IdP, but returns to the app without the callback URL, the flag is never reset. If the session is then established viacheckAuthIncludingServer→forceRefreshSession(iframe silent renew),shouldStartPeriodicallyCheckForConfigkeeps readingisCodeFlowInProgress === trueand always returnsfalse— so tokens are silently never renewed.Unlike
isSilentRenewRunning,isCodeFlowInProgresshas no self-healing timeout.Fix
Reset the flag in
checkAuthWithConfigwhenever the current URL is not a callback. If the app loads without a callback URL, there is no in-flight code flow to protect, so the flag should be cleared. This is the minimal, defensive fix suggested in the issue, and it does not interfere with iframe silent renew (gated by the separateisSilentRenewRunningflag) or the existing reset on the callback path.Tests
Added two tests to
check-auth.service.spec.ts(written test-first):Verification
npm run test-lib-ci)npm run lint-libclean🤖 Generated with Claude Code