我正在使用AppAuth-iOS进行AD B2C登录,AppAuth-iOS使用SFAuthenticationSession在iOS 11+上进行身份验证请求。我假设当我调用SFSafariViewController来打开一个通过B2C执行SSO的Web应用程序的链接时,它将自动向其中的用户身份验证。但是,这似乎不起作用。
这不行吗?我做错了吗?
我尝试在项目中修改AppAuth-iOS窗格,并尝试在Web视图中打开身份验证请求,并使用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];
我希望SSO将在SFAuthenticationSession和SFSafariViewController之间工作。
非常感谢您。
答案 0 :(得分:0)
我假设您尝试使用WKwebView。如果是这样,wkwebview不会与Safari Web浏览器共享cookie。每个Web视图的运行过程都与我们隔离过程不同。