Skip to content

fix(auth): clear provider sessions on sign-out without linking the Facebook SDK - #2499

Open
demolaf wants to merge 49 commits into
pre-GAfrom
fix/signout-provider-sessions
Open

demolaf wants to merge 49 commits into
pre-GAfrom
fix/signout-provider-sessions

Conversation

@demolaf

@demolaf demolaf commented Sep 9, 2026

Copy link
Copy Markdown
Member

FirebaseAuthUI.signOut() never cleared the provider-side session. Both provider logout helpers ran after auth.signOut() had already cleared currentUser, and their guard tested FirebaseUser.providerId, which the SDK always reports as "firebase", so neither ever executed. A Google user's saved credential state survived sign-out, silently re-selecting the same account on the next sign-in instead of showing the picker, and a Facebook user was never logged out.

signOut() now reads the linked providers from providerData before signing out of Firebase, then clears each provider's session from the call site. The Facebook branch is additionally gated on ProviderAvailability.IS_FACEBOOK_AVAILABLE, since facebook-login is compileOnly and providerData can carry facebook.com for an account linked on another platform. Both helpers lose their now-unreachable internal guard and unused auth parameter; signOutFromGoogle rethrows CancellationException instead of swallowing it.

Added two FirebaseAuthUITest cases and the first e2e coverage of FirebaseAuthUI.signOut(), verified to fail on the old code and pass with the fix. Three pre-existing tests stubbed mockUser.providerId to values the real SDK never returns, which is what hid the bug; those stubs are gone.


Maintainer note: Fixes internal CPRN-435

demolaf and others added 30 commits September 7, 2026 13:25
…tion that owns it (#2454)

* refactor(auth): let the phone screen own its verification loading state

* fix(auth): read auth state per authUI instance when clearing loading on dispose
…eption fallback exhausts

(cherry picked from commit 6fa4f00)
(cherry picked from commit aca99e7)
(cherry picked from commit 8784b13ce29739ed7785aab9ab6fe4faad2a2981)
…data

(cherry picked from commit 8eca4fa)
(cherry picked from commit ac61312)
(cherry picked from commit 126ba985660ff272dbfda427b644ad4fb1ca6197)
…loop

(cherry picked from commit a87cfe3)
(cherry picked from commit 3f4ae70)
(cherry picked from commit 1f1ada380039ed5e7476dfc2e38a683e6edb4549)
…lot (#2452)

* feat(auth): reshape reauthContent into a ReauthContentState content slot

* fix(auth): address reauth review findings and retain state across recreation

* refactor(auth): make reauthentication a request-scoped state machine

* fix(auth): keep a proved reauthentication alive when its operation signs out

* fix(auth): tear down phone verification when a reauthentication attempt fails

* test(auth): cover sign-out-during-retry and phone reauth failure end to end

* test(auth): drop the flaky phone reauth e2e case
…lment (#2462)

* test(auth): pin onComplete and factor refresh on successful MFA enrollment

* test(auth): pin the SMS MFA enrollment route through send, verify and resend

* test(auth): pin the missing TOTP secret guard and the resend's clean enroll
…slot's sheet chrome (#2476)

* test(auth): cover the three recoveries that write a value through to the step they move to

* test(auth): assert a custom reauth slot's email and phone steps stay inside the library sheet
demolaf and others added 18 commits September 7, 2026 13:25
…2477)

Co-authored-by: Russell Wheatley <russellwheatley85@gmail.com>
…2492)

Co-authored-by: Russell Wheatley <russellwheatley85@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the sign-out flow in FirebaseAuthUI to ensure that provider-side sessions (Google and Facebook) are cleared properly. Since auth.signOut() clears the current user, the linked providers are now captured from providerData beforehand. Additionally, the Facebook sign-out logic is guarded to handle cases where the Facebook SDK is not present at runtime. Feedback on these changes suggests avoiding catching Throwable in signOutFromFacebook to prevent swallowing critical JVM errors, recommending catching LinkageError and Exception separately instead.

Comment on lines 242 to 246
try {
if (Provider.fromId(auth.currentUser?.providerId) != Provider.FACEBOOK) return
loginManagerProvider.logOut()
} catch (e: Exception) {
} catch (e: Throwable) {
Log.e("FacebookAuthProvider", "Error during Facebook sign out", e)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching Throwable is generally discouraged as it swallows critical JVM errors such as OutOfMemoryError, StackOverflowError, or ThreadDeath. Since the Facebook SDK is a compileOnly dependency, missing classes will throw a NoClassDefFoundError (which extends LinkageError). Catching LinkageError and Exception separately allows you to safely handle both the missing SDK scenario and any runtime exceptions without swallowing critical system errors.

    try {
        loginManagerProvider.logOut()
    } catch (e: LinkageError) {
        Log.e("FacebookAuthProvider", "Facebook SDK not available or mismatched", e)
    } catch (e: Exception) {
        Log.e("FacebookAuthProvider", "Error during Facebook sign out", e)
    }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, narrowed to LinkageError plus Exception. That covers both compileOnly failure modes (absent SDK, version mismatch) without swallowing OutOfMemoryError and friends.

@demolaf
demolaf force-pushed the fix/signout-provider-sessions branch from bca0e64 to 2404066 Compare September 9, 2026 14:35
@demolaf
demolaf changed the base branch from version-10.0.0-beta05 to pre-GA September 14, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant