Open merzchr opened 4 years ago
Hi guys, i have to push this topic again. If some is interested in a consulting project here. It would be great to get a message. Best Christsian
Let's dissect this a bit, shall we?
When using AppAuth
in your iOS App, you would start your authentication:
let authorizationRequest = OIDAuthorizationRequest(....)
OIDAuthState.authState(byPresenting: authorizationRequest) { authState, authError in
// handle authState or error
}
Safari Authentication Session |
---|
![]() |
Under the hood, this will use SFAuthenticationSession
(iOS 11) or ASWebAuthenticationSession
(iOS 12+).
Both sessions will open a Safari View-Controller within the context of your app.
This Safari instance has access to the global iOS cookie and session cache.
That's the same cookie and session cache that the default iOS Safari browser app is using.
So, if your user is authenticating either in the Safari browser app or in your app (via the mentioned XY-AuthenticationSession
), you will have access to the user's session.
Hi Leviathan,
but that is only true if it's a persistent cookie and not a session cookie. Also if you somehow need to add web content inside ob the app (inAppBrowsing with SafariViewController or WKWebView), that would not work as well if we have SFAuthenticationSession (iOS 11) or ASWebAuthenticationSession (iOS 12+).
So for that case i don't see any solution or does somebody has an idea how it would be possible to solve this?
Hi Leviathan, Markus mentioned exactly my challenge :/ Best Christian
Hi, looks like I'm facing the same issue.
Hi guys,
Do you know if there is a way to not use SFSafariViewController
and open Safari app instead?
I second the above. Expectation is when I logged in on iOS app and the WebView controller launches, it should have save the cookie as persistent, so that when I access my web app on Safari, it should be able to read the cookie and logged in automatically.
On AppAuth-Android, the behavior is working correctly. Only here in iOS the cookie is session based. Is there anyway configuration to make the cookie persistent?
Hi guys, I am facing the same issue, maybe some one have resolve this issue?
Hi, did anyone found a solution please ?
I did quite some testing for SSO between browser and app using an ASWebAuthenticationSession and setting prefersEphemeralWebBrowserSession to false. Based on this article https://developer.okta.com/blog/2022/01/13/mobile-sso#sfauthenticationsession-or-aswebauthenticationsession-behavior and the Apple docs (https://developer.apple.com/documentation/authenticationservices/authenticating_a_user_through_a_web_service#3395310) that should be possible.
my reproduction path:
This is the ASWebAuthenticationSession when debugging:
Here is a comparision between the cookies in Safari vs. the cookies in the webview:
Conclusion: For some reason the cookies are not shared between Safari en the Webview, but not sure why...
Any updates? I have the same issue: signed in with AppAuth, want to use the session cookie for SSO in an embedded webview.
Regarding webviews: AppAuth isn’t going to help us with them, because its job is to avoid webviews like the plague.
Embedded user-agents do not share the authentication state with other apps or the browser. (RFC 8252 Section 8.12)
<Disclaimer: I have not done this, use these ideas at your own risk. I’ve just been sitting here noodling on it and putting some pieces together...and I think it ought to work something like this.>
Think of the webview as part of the native app. The app knows who the user is by virtue of the id token it received. The app can request resources from APIs using the access token it received. So, it follows that the webview should also make use of these tokens (since the webview is part of the native app.)
One could inform the webview of the access token by passing it in. (Example)
Then, it’s up to the webview to send the access token (JWT) to the website it wants to access. (MVC examples in these answers)
Any updates? I have the same issue: signed in with AppAuth, want to use the session cookie for SSO in an embedded webview.
Are you testing on a real device or an emulator? For me it was working after all when testing on a real device.
I am having the same issue. I am using keycloak and appear to need the KEYCLOAK_IDENTITY
cookie to persist or be available for my WKWebView.
I have tested on a real device with the latest version of keycloak.
No someone is testing on my device without my permission Sent from my iPhoneOn May 10, 2024, at 5:06 PM, John Waters @.***> wrote: Any updates? I have the same issue: signed in with AppAuth, want to use the session cookie for SSO in an embedded webview.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
Dear AppAuth-iOS Community, is there a possibility to remember my OIDC credentials when im switching between native iosApp & common Safari Browser on my ios device?