Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix keychain access issues caused by prewarming #9622

Merged
merged 7 commits into from Apr 19, 2022
Merged

Conversation

rosalyntan
Copy link
Member

@rosalyntan rosalyntan commented Apr 8, 2022

Fix keychain access issues in iOS 15 that are caused by prewarming.

For SwiftUI developers, the prewarming sequence means that init may be called before the device is unlocked, with the result that protected data in the keychain is unable to be accessed.

For UIKit developers, while according to the documentation didFinishLaunchingWithOptions should not be called as part of the prewarming sequence, these Apple forum answers [1][2] indicate that didFinishLaunchingWithOptions is sometimes called during prewarming, before protected data in the keychain is accessible.

To solve this issue, we can check isProtectedDataAvailable before accessing the keychain, and if it is unavailable, listen for the UIApplicationProtectedDataDidBecomeAvailable notification.

Fixes #8695

Copy link
Member

@ryanwilson ryanwilson left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just a comment about platform availability!

FirebaseAuth/Sources/Auth/FIRAuth.m Outdated Show resolved Hide resolved
FirebaseAuth/Sources/Auth/FIRAuth.m Outdated Show resolved Hide resolved
@rosalyntan rosalyntan changed the title Test fix. Fix for keychain access issues caused by prewarming Apr 9, 2022
@rosalyntan rosalyntan changed the title Fix for keychain access issues caused by prewarming Fix keychain access issues caused by prewarming Apr 9, 2022
@rosalyntan rosalyntan marked this pull request as ready for review April 11, 2022 17:47
@google-oss-bot
Copy link

google-oss-bot commented Apr 13, 2022

@paulb777
Copy link
Member

Marking for consideration for Firebase 9 milestone.

@paulb777 paulb777 added this to the Firebase 9 milestone Apr 15, 2022
@rosalyntan rosalyntan merged commit dc45185 into master Apr 19, 2022
@rosalyntan rosalyntan deleted the rosalyntan.keychain branch April 19, 2022 23:03
@firebase firebase locked and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firebase Auth - Signing users out after 30 minutes (As of Xcode 13, iOS 15 SDK).
4 participants