Skip to content

Web - SSO/SAML - User unable to sign out, a new windows always open #90114

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.69-3
Reproducible in staging?: Yes
Reproducible in production?: N/A - new feature, doesn't exist in prod
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #89894
Email or phone of affected tester (no customers): applausetester+saml1@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Pull Request QA execution
Device used: Windows 11 / Chrome
App Component: Other

Action Performed:

Precondition:

  • SAML requirement for login is enabled
  1. Open https://staging.new.expensify.com/
  2. Sign in via SSO (you can use applausetester+saml1@applause.expensifail.com)
  3. Navigate to Account > click Sign out

Expected Result:

User should be able to sign out successfully

Actual Result:

When attempting to sign out after signing in via SSO, a new browser window opens and redirects to the Profile page. If you close this window and click 'Sign out' again, the SSO login page will appear again.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7148960_1778300374097.90006_-_PR89894_-_Web_-_SSOSAML_-_User_unable_to_sign_out__a_new_windows_always_open.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    on May 9, 2026
  2. melvin-bot commented on May 9, 2026

    @melvin-bot

    @AndrewGable recently merged #89894, but they are OOO right now, so I'll auto-assign someone else.

  3. melvin-bot commented on May 9, 2026

    @melvin-bot

    Triggered auto assignment to @stitesExpensify (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on May 9, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on May 9, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on May 9, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #89894 - "Preserve information about saml session when logging out previous user" by @jnowakow (High confidence)
    Related Issues: N/A

    Recommendation: REVERT

    PR #89894 introduced a regression in the SAML sign-out flow on web. The fix passes isSAML=true from URL params into the session state (signedInWithSAML: true), which causes the logout path to invoke the SAML single logout (SLO) flow via callSAMLSignOut. On web, that function calls openAuthSessionAsync, which opens a new browser popup — exactly the behavior described in the bug report. The change is small (4 lines), touches only one file, and has a clean revert target.

    Assigned: @jnowakow (PR author), @AndrewGable (approving reviewer)
    Labels: DeployBlockerCash kept (Frontend bug in App PR). No label changes made.

    Detailed Analysis

    Evidence

    Verification

    • Affected file: src/pages/LogOutPreviousUserPage.tsx — this is the only file changed by PR Preserve information about saml session when loging out previous user #89894
    • Mechanism: PR Preserve information about saml session when loging out previous user #89894 extracts isSAML from route params and passes it as the second argument to signInWithShortLivedAuthToken(shortLivedAuthToken, !!isSAML). This causes getShortLivedLoginParams to set signedInWithSAML: true in the Onyx SESSION store.
    • Sign-out path: signOutAndRedirectToSignIn calls signOut({signedInWithSAML: !!session.signedInWithSAML, authToken: session.authToken}). With signedInWithSAML=true, the signOut function branches into callSAMLSignOut.
    • Root cause behavior: callSAMLSignOut on web calls openAuthSessionAsync, which opens a browser popup directed at the SAML logout URL. The popup opens and redirects to the Profile page (as reported), rather than performing a clean in-app logout.

    Root Cause

    Before PR #89894, signInWithShortLivedAuthToken was always called without the isSAML flag (defaulting to false), so the session never had signedInWithSAML: true set via the LogOutPreviousUserPage path. After the PR, if a user signs in via SSO (SAML), the isSAML URL param is present, and the session is now marked with signedInWithSAML: true. When the user subsequently signs out via the normal UI path, the SAML single logout (SLO) flow is triggered — opening a new browser window — instead of the standard logout, causing the broken sign-out experience reported.

  7. MelvinBot commented on May 9, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    PR #89894 correctly started preserving the isSAML flag in LogOutPreviousUserPage.tsx:60 so that session.signedInWithSAML is set to true for users who sign in via SSO through OldDot transitions. This means that when these users click "Sign out", the code now takes the SAML logout path via callSAMLSignOut.

    callSAMLSignOut uses openAuthSessionAsync to open a popup window to the SAML logout endpoint. After the IdP SLO flow completes, the popup redirects back to CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL. The popup loads the full App, and maybeCompleteAuthSession() runs to send a postMessage back to the opener window to resolve the auth session.

    The problem is that maybeCompleteAuthSession (from expo-web-browser) compares the popup's current URL against the stored expected redirect URL. If they don't match (e.g., the SAML backend redirects to a different URL than what CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL resolves to on staging), the auth session silently fails. The popup stays open showing the authenticated app (Profile page), openAuthSessionAsync never resolves with 'success', and when the user closes the popup, it resolves with 'dismiss' causing callSAMLSignOut to reject with "Logout cancelled". The .catch on line 479 just logs a warning, so redirectToSignIn() is never called and the user remains logged in.

    What changes do you think we should make in order to solve the problem?

    The fix should ensure the SAML logout endpoint query string includes an explicit redirect URL matching the current origin so that the popup redirects back to the correct URL.

    In callSAMLSignOut, the web query string currently only passes referer=ecash&authToken=.... It should also include an explicit redirect parameter with CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL (or window.location.origin) so the SAML backend knows exactly where to redirect after logout — ensuring the URL matches what expo-web-browser expects.

    If the backend doesn't support a redirect parameter, an alternative approach is to handle the 'dismiss' result from openAuthSessionAsync more gracefully — instead of rejecting the promise, proceed with the LOG_OUT API call anyway (since the SAML IdP session was already terminated by the popup navigation, the only remaining step is invalidating the local Expensify session).

    What alternative solutions did you explore? (Optional)

    1. Reverting PR Preserve information about saml session when loging out previous user #89894 — This would fix the immediate regression but re-break the original issue that PR was solving (preserving SAML session info during OldDot transitions).
    2. Modifying maybeCompleteAuthSession matching — Could use origin-only comparison instead of full URL, but this is in expo-web-browser (a dependency) and would be fragile.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  8. jnowakow commented on May 11, 2026

    @jnowakow
    Contributor

    @lanitochka17, are use using staging server or production server when testing this?

  9. lanitochka17 commented on May 11, 2026

    @lanitochka17
    Author

    stg

    Recording.5560.mp4
  10. AndrewGable commented on May 11, 2026

    @AndrewGable
    Contributor

    We are reverting to fix the deploy blocker

  11. m-natarajan commented on May 11, 2026

    @m-natarajan

    Passed, Chrome / v9.3.69-15

    REC-20260511224107.mp4
  12. removed
    DeployBlockerCash
    on May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringHourly

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions