Skip to content

fix: reset abandoned code flow flag on non-callback checkAuth (#2221)#2224

Open
FabianGosebrink wants to merge 1 commit into
mainfrom
fix/reset-code-flow-in-progress-on-non-callback
Open

fix: reset abandoned code flow flag on non-callback checkAuth (#2221)#2224
FabianGosebrink wants to merge 1 commit into
mainfrom
fix/reset-code-flow-in-progress-on-non-callback

Conversation

@FabianGosebrink

Copy link
Copy Markdown
Collaborator

Summary

Fixes #2221 — the storageCodeFlowInProgress flag 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

resetCodeFlowInProgress is only called in CodeFlowCallbackService.authenticatedCallbackWithCode, which is reached only when the current URL contains an authorization code (isCallback === true).

When a user calls authorize() (which sets storageCodeFlowInProgress = 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 via checkAuthIncludingServerforceRefreshSession (iframe silent renew), shouldStartPeriodicallyCheckForConfig keeps reading isCodeFlowInProgress === true and always returns false — so tokens are silently never renewed.

Unlike isSilentRenewRunning, isCodeFlowInProgress has no self-healing timeout.

Fix

Reset the flag in checkAuthWithConfig whenever 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 separate isSilentRenewRunning flag) or the existing reset on the callback path.

Tests

Added two tests to check-auth.service.spec.ts (written test-first):

  • resets a previously abandoned code flow when the current URL is not a callback
  • does not reset the code flow when the current URL is a callback (the existing callback-path reset remains the single source of truth during real flows)

Verification

  • ✅ 995/995 lib tests pass (npm run test-lib-ci)
  • npm run lint-lib clean
  • ✅ Prettier clean

🤖 Generated with Claude Code

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>
@damienbod

Copy link
Copy Markdown
Owner

I would need to verify that this has no side effects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: storageCodeFlowInProgress flag never reset when checkAuthIncludingServer establishes session via SSO silent renew after an abandoned code flow

2 participants