我正在使用 AppAuth-iOS 进行 AD B2C 登录,AppAuth-iOS 使用 SFAuthenticationSession 在 iOS 11+ 上发出身份验证请求。我假设当我调用 SFSafariViewController 打开一个指向与 B2C 进行 SSO 的 web 应用程序的链接时,它会自动对用户进行身份验证。但是,这似乎不起作用。
它不应该工作吗?我做错了吗?
我尝试在我的项目中修改 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];
我希望 SSO 将在 SFAuthenticationSession 和 SFSafariViewController 之间工作。
非常感谢你。