-
Notifications
You must be signed in to change notification settings - Fork 898
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
Login to Firebase does not work on Safari 16.1+ #6716
Comments
Hello, today 16.1 version was released, and this problem still continues. Can you help us with this problem, please? |
Hi folks, we're still diagnosing the particular issues at play, but it appears that A full write-up of potential mitigations can be found in #6443 (comment) |
hey thanks for the update. just to save anyone else reading this some time, while we have the |
Yes, sorry I should have noted that that comment was for Firefox, but we believe it may be a similar underlying mechanism that's causing the user not to be populated. Mitigation 3 from that list does not use
|
We are also experiencing this error. Using I believe this is related to this [prematurely] closed issue: #6636 Unfortunately the instructions^ for manually signing in only seem to apply to GoogleProvider, which does not pertain to us |
Can confirm this is happening on 16.1 Safari, including iOS 16.1. The suggested solutions all have flaws:
Does it look like there are any other solutions in sight? Can we switch to some cookie-based authentication possibly? As 16.1 rolls out this is going to affect a huge number of users. Thanks! cc @sam-gc @prameshj |
This likely has the same cause as #6443. |
We are exploring a few options for a longer-term fix. Cookie-based authentication will run into this same limitation since the oauth helper code is in <project>.firebaseapp.com domain (or the firebase hosting domain, if specified in the authDomain parameter). If this domain is different from the domain where the app is running, there is a cross-origin storage access to complete sign in, which gets blocked by some browser policies. Note that the FirebaseUI Web issue(firebase/firebaseui-web#977) is different and presents with a "TypeError: Right side of assignment cannot be destructured" in the console. |
Curiously on iOS 16.1, Chrome and Firefox and Brave also suffer the same issue as Safari!
(Latest versions of Chrome and Firefox and Brave on MacOS still function using |
There is only one actual browser on iOS: Safari. The other browsers use Safari beneath their own UI/UX. |
Hello, is anyone still meet this issue ? since on my environment, I cannot meet in that means reproduce this phenomenon iOS 16.1 and safari with iPhone 14 pro |
@prameshj: If you want a privacy engineer at Mozilla to talk to, I can chat about some of these options! |
Now that Safari 16.1 is released, this is affecting users. Are there any manual work arounds (like implementing the party flow not using the SDK) that we could implement? Also if there is anything I can help with testing, let me know. |
Ok. Been doing some digging into this and I can confirm that I think the one thing that catches people out when implementing |
Does |
@galaxyblur we have tried to use |
Hmm... I'm pretty sure some mobile web browsers, like Chrome iOS, block popups by default, even when they are the result of an action from the user. Or at least there is a setting to do this. Even if that's not the case, there's still other pitfalls: signInWithPopup will not work with in-app web views, and it can fail for a variety of reasons even on desktop — for example an aggresive adblocker. Our strategy is to try
@prameshj, do you or the Firebase team have an estimate/idea of if there is a fix for this in the short term? Any updates are appreciated — if there is no short-term fix on the horizon, our team needs to seriously consider implementing the OAuth providers ourselves, and only using Firebase SDK to get a FIrebase token (suggestion 3 of #6443 (comment)). This is obviously a fairly large resource commitment, so we'd like to know if there's any other possible solutions in the works... |
I 2nd that -- knowing whether a fix in possible in the near term would help a great deal. |
I also would like to know when a fix is planned. If it comes to having to re-implement apple/Google/Twitter auth manually via OAuth, maybe this can be shared among the community here so everyone here can benefit from it. |
Hi all, thanks for your patience on this issue.
In addition to the workarounds listed here, there is the option to self-host the signin helper code. Here is a flowchart to determine the most suitable mitigation depending on the setup: Self-Hosting the widgets: Note: This approach will not work for Apple sign in and SAML. Please use a different mitigation for those. The When authentication flow returns to your app domain, the browser storage of the sign-in helper Hosting the helper code has the following steps:
Here is a sample server implementation that downloads and hosts the files - https://go.dev/play/p/qnI8PEPwME6
|
We will document these mitigation options in the official docs and drop a link here soon. We are investigating options for a more permanent solution, however, we do not have an ETA right now. |
Looks like there is a missing Also FYI -
|
Thanks! fixed. |
Out of curiosity, if we are self-hosting. I wonder if setting up a webserver proxy to these files would be a slightly more long-term/resilient option, rather than downloading and hosting the files directly (and risking them going out of date.) E.g.: Forwarding nginx example config:
If so, additionally, I wonder if this is something that might be added as an optional firebase configuration anyway (thus removing the need for the EDIT: On further inspection, I see that's what your example server script is essentially doing. And I've now verified this and it works. |
Hi @lincolnthree , you are right.. Setting up a reverse proxy on your app domain to route "/auth" requests to https://.firebaseapp.com//auth would be a more resilient and elegant solution. Thanks! You're right.. the example script does almost the same thing, but it does cache the files locally, but can be modified to sync the files periodically or proxy to the |
@prameshj |
The list of mitigations have been published at https://firebase.google.com/docs/auth/web/third-party-storage-mitigation
@sww314 if you are not on Firebase Hosting, then https://firebase.google.com/docs/auth/web/third-party-storage-mitigation#mitigation_3_proxy_auth_requests_to_firebaseappcom should work. |
I have a similar problem |
I was stuck with the same issue. Performing the 'redirect' firebaseui login Facebook login failed on iOS16 both in Safari and through the Facebook WebView. As stated above, option 2 here worked for me: #6443 (comment) |
…ssue that is returning empty users when signinwithredirect is used - this is not a permanent solution as the signinwithpopup is rife with issues on mobile either being blocked by popup blockers for various users etc - hoping to see some issue clearance from the webkit team soon - github issue ref is firebase/firebase-js-sdk#6716
Would it be possible to add an example to the documentation for how to do a reverse proxy in Flask, as we run on app engine on custom domain? for mitigation Option 3: Proxy auth requests to firebaseapp.com |
I believe this should be fixed in Firebase Authentication itself. It should not rely on cross-domain session storage, and I'm astonished that this has been considered a valid solution in the first place. The reverse proxy works, but may require extra work if you have a solid CSP. For instance, for the reverse proxy to work with safe and XSS resistant See @prameshj 's replies below for a CSP-friendly solution with nonce You might also need to update the default-src / frame-ancestors / script-src policies to include Firebase auth domain. |
Hi folks, thanks for pointing out this workaround. However, we do not recommend this approach since the script contents might change anytime. We will add a nonce to the inline script so that can be used as described in https://content-security-policy.com/examples/allow-inline-script/, so it will be a more stable value that can be allowlisted. I will update this thread once we roll this out. We are working on removing the inline js and will use #5193 to track this. |
@prameshj Thank you for the quick response. A nonce is a fair solution, and I'm glad to hear that the inline JS is being removed. This will make the issue much less painful on our end. I'll update my message to remove the workaround once the nonce is live (to avoid confusion). |
Is Fingerprint JS a service like described in https://blog.khophi.co/getting-started-with-fingerprintjs-pro/? I wonder if the error is just saying that __/auth/iframe code is not hosted in customdomain.com (but it at .firebaseapp.com) and is flagging that as potentially malicious. Is there a way to allowlist this URL path? |
Thanks @klemola .. you should now see a nonce around the inline JS in auth/handler and auth/iframe.
|
the "getClientIdentity" in the stacktrace isn't coming from the auth sdk or the auth helpers... Do you have more info on where that code is from? |
It seems like this change caused our CSP to start blocking Firebase Google login on our site. We already had nonce configured, and injected to every script tag on the page through Nginx. Here's the error when we try to login via Google:
When looking at the inline js tags the Firebase SDK pulls in, one of them now has two nonce, one from our Nginx and one
Any ideas how to work around this @prameshj? This starting failing few hours ago, sounds like that was around a similar time the |
Are you able to use the "firebase-auth-helper" nonce instead of the dynamically generated nginx nonce? Or can you allowlist "firebase-auth-helper" as an accepted nonce? I believe this would be in the "add-header" section of the nginx config. Like |
I think the main problem for me right now is that the script tag has two nonce, I assume that won't work. Currently figuring out how I can get Nginx to not inject a nonce for that particular script tag. Right now we're using a very simple Resulting in two nonce on this element:
|
You could modify the filter to replace |
Removing the
Why was that nonce being added in the first place? 🤔 |
See #6716 (comment) |
Hi @prameshj, everyone, I followed [Option #4] (https://firebase.google.com/docs/auth/web/redirect-best-practices#self-host-helper-code) but still wasn’t able to actually run the code in the handler file at “myappdomain/__/auth/handler”. It’s always downloading the handler file instead of executing it. The other options are not feasible for me since my hosting is done on cloudfront and a pop up won’t be optimal for my users. I must be missing something. Do you have an idea on what might be happening? |
Can you ensure that calls to GET “myappdomain/__/auth/handler” are returning html back? This will look similar to
You can create an HAR file in the browser to ensure the calls to download handler, followed by handler.js, experiment.js are all being issued. |
Fixed @prameshj |
We found that this actually had nothing to do with Firebase or this open issue at all. The error and code injection was caused by our web application firewall. We just happen to notice it at the time we added the Firebase proxy to work around this open issue and drew an incorrect conclusion. Thank you. |
Thank you so much for closing the loop here! |
Closing this issue since following the best practices at https://firebase.google.com/docs/auth/web/redirect-best-practices fixes this. |
I am having similar issues like this comment here: #6716 (comment) |
Adding the following rewrite to
|
Describe your environment
Describe the problem
Steps to reproduce:
Try logging in to a site using
signInWithRedirect
. Notably it redirects back to the site without an error, and does not log the user in. CheckinggetRedirectResult
returns a null user.This seems like a severe issue as iOS 16.1 will be released next week and presumably this issue will affect all those iOS users.
Notably there seems to be a workaround of using
signInWithPopup
. It seems to work for us, though it is unclear why.Relevant Code:
The text was updated successfully, but these errors were encountered: