firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

Unreliable Auth state shared with app extension using same access group

Open cybergen78 opened this issue 3 years ago • 11 comments

Environment

  • Xcode version: 12.2
  • Firebase SDK version: 7.1.0
  • Installation method: CocoaPods
  • Firebase Component: Auth

Description

After logging out and in again in the main app, AuthStateDidChangeListener reports no logged in user in the app extension until the calling app is restarted.

Steps to reproduce:

Assume we have a main app and a share extension. The share extension can be called from other apps (e.g. Amazon, Safari). Implement cross-app authentication with shared iOS Keychain as described here: https://firebase.google.com/docs/auth/ios/single-sign-on The share extension calls Auth.auth().useUserAccessGroup(<myKeychainAccessGroup>) like the main app does too and listens for the auth state with a AuthStateDidChangeListener.

  • Log in in the main app
  • Check user is also logged in in the share extension (e.g. by sharing a website from Safari)
  • Log out in the main app
  • Check user is also logged out in the share extension
  • Log in in the main app again
  • Check user is also logged in again in the share extension
After these steps:

Expected: User is also logged in again in the share extension Observed: User is not logged in in the share extension (user is nil in share extensions AuthStateDidChangeListener)

Weird solution:

Restarting the sharing/calling app (e.g. Safari) resolves the issue and the user is logged in again in the share extension despite the main app wasn't active in the meantime.

cybergen78 avatar Nov 19 '20 14:11 cybergen78

Would you mind sharing a minimal repro with a main app and sharing extension? That would help us a lot digging into it.

yuchenshi avatar Nov 24 '20 22:11 yuchenshi

Hey @cybergen78. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Dec 01 '20 02:12 google-oss-bot

It's a commercial product. I'll have to ask my employer if I may spend time on it. I'll get back soon, here.

cybergen78 avatar Dec 01 '20 09:12 cybergen78

I might be able to create a sample project in the week after next week. I'll keep you updated.

cybergen78 avatar Dec 08 '20 14:12 cybergen78

Hi @cybergen78, I just want to check if you're still encountering the issue. If so, please provide a sample project (MCVE) that will reproduce the issue so we could take a look what's causing it. Thanks.

rizafran avatar Apr 16 '21 12:04 rizafran

I didn't have time for this project since then. But I should have some time in the next 3 weeks. Sorry for the delay.

cybergen78 avatar Apr 16 '21 12:04 cybergen78

Eventually, I got the time to create an MCVE. I could reproduce the issue with this example project but it's even worse. In StarSnoopy at least the user is still logged out from the share extension if he/she logs out in the app itself. In the example app this doesn't work neither. However, I can't figure out the difference - the relevant code and configuration is the same.

FirebaseShareExtensionTest.zip

cybergen78 avatar May 04 '21 15:05 cybergen78

Thank you for creating the MCVE. I've filed an internal issue b/188421106 to track this.

weixifan avatar May 17 '21 16:05 weixifan

Any progress on that?

cybergen78 avatar Mar 01 '22 12:03 cybergen78

I am facing the same issue. Seems like the currentUser is being loaded the first time share extension context is being made and won't change unless you re-open the host app. It's weird. Dismissing the extension either by cancelling or completing won't affect the outcome.

mohpor avatar May 01 '22 14:05 mohpor

Any updates here?

kroussevrb avatar Feb 09 '24 09:02 kroussevrb