登录 SFAuthenticationSession 然后在执行 SSO 的 SFSafariViewController 中打开 link
Logging in SFAuthenticationSession then opening a link in SFSafariViewController that does SSO
我正在使用 AppAuth-iOS 进行我的 AD B2C 登录,AppAuth-iOS 使用 SFAuthenticationSession 在 iOS 11+ 上发出身份验证请求。我假设当我调用 SFSafariViewController 打开一个 link 到一个使用 B2C 进行 SSO 的 Web 应用程序时,它会自动对用户进行身份验证。然而这似乎不起作用。
它不应该工作吗?我是不是做错了?
我尝试修改我项目中的 AppAuth-iOS pod,并尝试在 webview 中打开身份验证请求并使用 webview 也打开 link.. 不起作用。另外,我读过有关 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];
我用这个代码打开link,
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:URL];
svc.delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[self presentViewController:svc animated:YES completion:nil];
我希望 SSO 能在 SFAuthenticationSession 和 SFSafariViewController 之间工作。
非常感谢。
我假设您尝试使用 WKwebView。如果是这样,wkwebview 不会与 Safari 网络浏览器共享 cookie。每个 Web 视图 运行 处于与我们隔离不同的进程中。
我正在使用 AppAuth-iOS 进行我的 AD B2C 登录,AppAuth-iOS 使用 SFAuthenticationSession 在 iOS 11+ 上发出身份验证请求。我假设当我调用 SFSafariViewController 打开一个 link 到一个使用 B2C 进行 SSO 的 Web 应用程序时,它会自动对用户进行身份验证。然而这似乎不起作用。
它不应该工作吗?我是不是做错了?
我尝试修改我项目中的 AppAuth-iOS pod,并尝试在 webview 中打开身份验证请求并使用 webview 也打开 link.. 不起作用。另外,我读过有关 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];
我用这个代码打开link,
SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:URL];
svc.delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[self presentViewController:svc animated:YES completion:nil];
我希望 SSO 能在 SFAuthenticationSession 和 SFSafariViewController 之间工作。
非常感谢。
我假设您尝试使用 WKwebView。如果是这样,wkwebview 不会与 Safari 网络浏览器共享 cookie。每个 Web 视图 运行 处于与我们隔离不同的进程中。