我使用AppAuth-iOS登录AD B2C,AppAuth-iOS使用SFAuthenticationSession在iOS 11+上进行身份验证请求。我假设当我调用SFSafariViewController打开一个指向使用B2C进行单点登录的when应用程序的链接时,它会自动对用户进行身份验证。然而,这似乎不起作用。
它不应该工作吗?我是不是做错了?
我已经尝试在我的项目中修改AppAuth-iOS pod,并尝试在webview中打开身份验证请求,然后使用webview打开链接。不起作用。另外,我读到过Safari不共享cookie的实例,这也适用于webview吗?webview是否使用Safari浏览器?我也读过与这个问题相关的其他东西,但它们让我感到困惑,最后,对我来说,它们并没有结束。
这是来自AppAuth-iOS的OIDExternalUserAgentIOS.m的代码,用于将应用程序与B2C登录进行通信:
SFAuthenticationSession *authenticationVC =
[[SFAuthenticationSession alloc] initWithURL:requestURL
callbackURLScheme:redirectScheme
completionHandler:^(NSURL * _Nullable callbackURL,
NSError * _Nullable error) {
__strong OIDExternalUserAgentIOS *strongSelf = weakSelf;
if (!strongSelf)
return;
strongSelf->_authenticationVC = nil;
if (callbackURL) {
[strongSelf->_session resumeExternalUserAgentFlowWithURL:callbackURL];我用这段代码打开链接,
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:URL];
svc.delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[self presentViewController:svc animated:YES completion:nil];我希望单点登录能在SFAuthenticationSession和SFSafariViewController之间工作。
非常感谢。
发布于 2019-09-21 08:58:50
我假设您尝试使用WKwebView。如果是这样,wkwebview不会与Safari web浏览器共享cookie。每个web视图运行在不同的进程中,而不是我们有一个隔离的进程。
https://stackoverflow.com/questions/54432641
复制相似问题