-
Notifications
You must be signed in to change notification settings - Fork 987
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
iOS 14 will enable Intelligent Tracking Prevention in WKWebView by default #922
Comments
It would also be very useful for these same cookies to be sent/supported on websocket connections from cordova-ios. |
On iOS14, still stuck on this ITP problem... I tried to disable ITP controls by adding Another unsuccessfully tested solution,
with also : |
iOS 14 stable is rolling out, we're having issues with our mobile app that uses an OAuth flow with the InAppBrowser |
Using the InAppBrowser for Oauth is not good. I think some providers
like Google even block that. Ypu could have a look at
SafarViewController or using the System Browser.
On September 28, 2020, GitHub ***@***.***> wrote:
iOS 14 stable is rolling out, we're having issues with our mobile app
that uses an OAuth flow with the InAppBrowser
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#922 (comment)-
699825945>, or unsubscribe
<https://github.com/notifications/unsubscribe-
auth/AA3LORGBLJJWYWMJIUPDJLLSIAZ5LANCNFSM4OJCAPRA>.
|
Until cordova handles this issue, a workaround is the following plugin to sync cookies. It worked in ios 14.0.1, which means server-set cookies sent in following requests. https://github.com/CWBudde/cordova-plugin-wkwebview-inject-cookie |
Hi, how is the value for NSCrossWebsiteTrackingUsageDescription key? A descriptive string or specific value? |
That repo does not work for iOS 14. |
@toddtarsi it worked on my project without problem. However i then found an easier way and used https://github.com/oracle/cordova-plugin-wkwebview-file-xhr instead. It worked lika a charm and apple approved the build. |
@ardabeyazoglu - I'm glad you've found a solution for your needs. I just want to make clear that the repo you referenced doesn't resolve this issue in all cases. We've used that repo to resolve cookie issues since iOS 10 I think, and it doesn't do it here. |
@toddtarsi have you tried xhr plugin i mentioned ? |
@ardabeyazoglu - I have not. Thanks for the recommendation. I don't think it will work for our use case however since we have a mix of secure, httpOnly cookies as well as non-secure cookies that we read from the JS layer. It seems like that solution doesn't allow for the latter use case. |
@ardabeyazoglu i've used https://github.com/CWBudde/cordova-plugin-wkwebview-inject-cookie for a long time. I'm going to check https://github.com/oracle/cordova-plugin-wkwebview-file-xhr if it helps. EDIT: Installed https://github.com/oracle/cordova-plugin-wkwebview-file-xhr and started working again. |
@ardabeyazoglu - I've started using the file xhr plugin, and it helps a lot. Thanks for the recommendation! Unfortunately, I'm still seeing authentication fail on websocket connect requests, but I'll try and figure out what I can do about that. |
@toddtarsi since websocket does not use fetch/xmlhttprequest, it has probably no use for that. There are 2 possible workarounds i think:
|
It could help if everyone here could comment here https://bugs.webkit.org/show_bug.cgi?id=213510 how they use Cordova and how ITP affects their apps. If Apple gets a better view about the apps out there and how they use the Webview, there is a small chance we can make Cordova better some day. |
Thanks to all for discussing the issue and also sharing your findings on the go. |
@tajindersinghnamdhari - These work very well if you're using the XHR / fetch APIs. The way cordova-plugin-wkwebview-file-xhr works is by directly polyfilling the XMLHttpRequest, FormData, and fetch APIs. If you're using any other networking components (in my case window.WebSocket), this will not resolve all issues. |
I have the same problem. The app have the plugin "cordova-plugin-wkwebview-inject-cookie" and no save the cookies, but only on iOS 14. In my case, I compiled with an old Xcode versión (v11.3.1 - 11c504) and cookies works again (temporal solution). |
Hi Everyone, I have had the same issue, and used the file-xhr plugin to resolve this. Not sure if there is another solution to this? |
Hello @NiklasMerz , I've got an hybrid app with cookie based authentication in production on the app store. |
Hi guys |
As far as my PR goes I think this could go into a minor release like 6.2.0. But we would need to wait for more reviews and feedback. As an interim solution you could use a fork of the iOS platform until this get's merged and test it if you know what you are doing. As far as WKAppBoundDomains goes I think it would be good if we get more information on how to get this implemented properly. This is not a solution for my personal use-case but it would be great if we can offer this for most apps where this is the right way to do it. If anyone has experience with WKAppBoundDomains please share. |
@NiklasMerz thanks for all the effort! |
@tudordumitriu That's exactly how I work as well. When I fix changes I contribute them as PRs and run of forks until they get released. You need to clean up occassionally and push PRs forward of course. To get this feature running you need to use the branch/fork of my PR and add the webview proxy plugin linked there. You then rewrite the url with the plugins JS helper functions and now your requests go through the proxy and your cookie issues are hopefully gone. If you need more help please contact me or better comment on the PR or the plugins issues/discussions to. |
Thanks, since we're not under live pressure (the live version still working - so I suspect the XCode 12 changed the game) we'll wait for a while to see how that goes, if it takes more than couple of weeks will use your fork. |
Same here - Hadn't been using ios 14 so apple caught the problem when trying to get them approved. Option 1 - I will be try this plugin A little confused on how to use this for my case. Option 2 - Is there another option, anything else that has worked? |
@newuser44 Sorry your comment is more a question and therefore off-topic. Please go to our slack to get support from other uses. http://slack.cordova.io |
Hi @NiklasMerz |
FWIW I managed to get my Cordova app to use authentication cookies set by the response of an XHR request to my remote without needing any plugins or hacks. There are some gotchas though and wanted to try to outline them here:
The last two aren't ideal, and I've created a feature request for cordova-ios to handle AppBoundDomains out of the box. If you're up against a deadline however, it's not too painful to add it yourself |
@adamdport Are the cookies only from mydomain.com in your setup or are you trying to access cross site cookies with that approach? |
@jeremyspatrick in my case, I'm making a login request to mydomain.com, the response of that request sets a cookie, and every subsequent request to mydomain.com includes that cookie until I log out. I don't have any other domains in my setup, but I could try to do some more testing in a few days if you have something specific you want me to test |
I have just taken over development of an app this week (with little app experience) as the previous developer left. Since he left, iOS login authentication fails - I believe this stems from when the previous dev updated XCode from 11 -> 12 two weeks ago. I have been following the posts here and on webkit for the past few days and still haven't found a solution, not even with the AppBoundDomains. Login works fine on browser and Android. Only on iOS devices and on the simulator/emulator it fails due to cookies. The only successful login I have managed to achieve on iOS is by adding this to the config.xml:
However, this only works for a single domain, and I need to support multiple. feelsbadman.jpg |
This doesn't do what you probably think this does. |
Yes correct, that line didn't affect anything - just the hostname. I guess I'm just clutching at straws at this point lol |
You are right the Xcode update changed the behavior. You need to figure out a way to work around this or better get rid of cookies for authentication. This was my journey. Maybe you get something out of it. https://blog.merzlabs.com/posts/webview-history/ |
Thanks, it is nice to have some confirmation that it was indeed the Xcode update, it has been an interesting takeover of the app so far. I think we will have to go without cookies as you say - I will checkout your blog also. I wonder if it is possible to build in an old Xcode version to get one final version released for now |
please fix these bugs. |
Cordova cannot fix these bugs. Apple (and eventually google) is deliberately blocking all third party cookies. The options are
|
@jeremyspatrick @victorvhpg I have been using the first one for a year without any problem, for multiple domains. xmlhttprequest and fetch api both work, except that you can't get cookie from native layer, it must be a httpOnly cookie, -which must be- when used for authentication to be more secure. I don't understand why this problem is still so annoying except few specific use cases such as websocket, as @toddtarsi mentioned. Even websocket issue can be solved by a few changes in the app, giving cookie back in body instead of header after authentication, and send it manually in websocket handshake. |
When i realized i couldn't get the cookie back into the wkview i didn't consider that a viable option. Yes you can route all traffic through a native layer but that doesn't help much for users that are relying on iframes. unless there's a way to sync cookies this way. not sure. unrelated to ios i just noticed #2 doesn't appear to work for android. I cannot set the origin by modifying config.xml. the origin is always file:// |
I face a similar problem with cookies on iOS (cordova-ios v7.1.0). Here is my config.xml
There is no SSO or InApp Browser mechanism enabled to set an authentication cookie. Authentication is done by sending an initial http request to the endpoint I also set the Does iOS treat cookies as "third-party" when the Any ideas? Thank you. |
Bug Report
Problem
Apple just announced that iOS 14 will enable "Intelligent Tracking Prevention" (ITP) by default in WKWebView. This issue is open for discussion around that and possible ways to fix Cordova apps that break with these changes. Please leave a 👍 if you are having issues with this change.
Possible solution -> Work in progress
localhost
in WebKit?Code - Workarounds
Currently the best solution in my case seems to build some kind of HTTP proxy with an WKURLSchemeHandler. I did this in the WKWebView plugin a while ago to workaround any CORS restrictions. Would this make sense to integrate into cordova-ios?
So the app runs on
cordova://localhost
for example and you convert every external URL likehttps://myserver.com/image.png
tocordova://localhost/_httpproxy/myserver.com/image.png
and the WKURLSchemeHandler does the server request instead with native Code instead of letting the WebView doing it.https://github.com/GEDYSIntraWare/cordova-plugin-ionic-webview/blob/proxyios/src/ios/IONAssetHandler.m#L38-L85
GEDYSIntraWare/cordova-plugin-ionic-webview@master...GEDYSIntraWare:proxyios
Information
WKWebView session from WWDC 2020
Webkit bug report
Environment, Platform, Device
iOS 14 beta
Checklist
The text was updated successfully, but these errors were encountered: