首页 > 解决方案 > Iphone 认证用户未重定向到应用程序

问题描述

我正在使用带有 IdentityServer4 的 AspNetCore 2.2.0。

重现问题的问题/步骤 我使用 iPhone 进行“使用苹果登录”。点击本机应用程序中的登录按钮会打开一个登录网页,该网页托管在 windows docker 容器中。在登录网页上,单击“使用 Apple 登录”会显示 IOS 原生弹出窗口以继续使用已与该应用关联的帐户或“使用不同的 Apple ID”。点击继续按钮时,会显示一个白色屏幕,该屏幕冻结在 appleid.apple.com 上并且没有任何反应。 iPhone本机弹出点击继续导致白屏 此外,如果该应用在首次正常运行之前未与任何 Apple ID 关联。在退出并尝试使用上述步骤登录时,出现白屏。“使用不同的 Apple ID”流程运行良好。我不确定我的代码或 IdentityServer4 中是否有任何错误。根据日志,正在从 Apple 接收回调 /connect/authorize/callback,但它不会反映在浏览器上。非常感谢任何帮助。

日志文件的相关部分 trce:IdentityServer4.ResponseHandling.AuthorizeInteractionResponseGenerator[0] ProcessInteractionAsync dbug:Equinox.Account.Services.EquinoxProfileService[0] IsActive 调用自:AuthorizeEndpoint dbug:IdentityServer4.Services.DefaultConsentService[0] 客户端配置为不需要同意,不需要同意dbug:IdentityServer4.Endpoints.AuthorizeCallbackEndpoint[0] dbug:IdentityServer4.ResponseHandling.AuthorizeResponseGenerator[0] 创建混合流响应。dbug:Equinox.Account.Repositories.PersistedGrantsRepository[0] MAbolcoMM9bi+QcW7FVOgryzkOBZXiPRZzpw4R1UAWk= 在数据库中找不到 dbug:IdentityServer4.ResponseHandling.AuthorizeResponseGenerator[0] 创建隐式流响应。trce:IdentityServer4.Services。“mymobileapp”,RedirectUri:“mymobileapp://oauthredirect”,范围:“openid profile email offline_access”} trce:IdentityServer4.Endpoints.AuthorizeCallbackEndpoint[0] 结束授权请求。结果类型:IdentityServer4.Endpoints.Results.AuthorizeResult trce:IdentityServer4.Hosting.IdentityServerMiddleware[0] 调用结果:IdentityServer4.Endpoints.Results.AuthorizeResult dbug:IdentityServer4.Hosting.IdentityServerAuthenticationService[0] 增强 SignInContext dbug:Equinox.Account.Repositories。 PersistedGrantsRepository[0] 8RotaoHQ32K7iyNlN61q0700M47i1Fx0 在数据库中找不到 AuthorizeCallbackEndpoint[0] 结束授权请求。结果类型:IdentityServer4.Endpoints.Results.AuthorizeResult trce:IdentityServer4.Hosting.IdentityServerMiddleware[0] 调用结果:IdentityServer4.Endpoints.Results.AuthorizeResult dbug:IdentityServer4.Hosting.IdentityServerAuthenticationService[0] 增强 SignInContext dbug:Equinox.Account.Repositories。 PersistedGrantsRepository[0] 8RotaoHQ32K7iyNlN61q0700M47i1Fx0 在数据库中找不到 AuthorizeCallbackEndpoint[0] 结束授权请求。结果类型:IdentityServer4.Endpoints.Results.AuthorizeResult trce:IdentityServer4.Hosting.IdentityServerMiddleware[0] 调用结果:IdentityServer4.Endpoints.Results.AuthorizeResult dbug:IdentityServer4.Hosting.IdentityServerAuthenticationService[0] 增强 SignInContext dbug:Equinox.Account.Repositories。 PersistedGrantsRepository[0] 8RotaoHQ32K7iyNlN61q0700M47i1Fx0 在数据库中找不到

更新:我仍在努力解决这个问题。经过进一步调试,结果发现,当自定义端点“auth/apple”删除了 auth cookie 创建时,重定向发生在登录页面中 - 很明显,没有身份验证,控件进入登录页面。否则,会出现白屏。下面是代码片段

AuthenticationProperties props = null;
HttpContext.SignInAsync(account.Username, account.Username, props).Wait();

由于 auth cookie 可能导致白屏的原因非常令人惊讶。如果有人可以分享任何建议,我将不胜感激?

标签: iosiphone.net-coreidentityserver4apple-sign-in

解决方案


由于 Safari 浏览器的安全性,问题已解决并显示白屏。由于 cookie 是从 appleid.apple.com 创建到我的主机 login.mysite.com 的。尽管正在创建 cookie(如 charles session 中所见),但进度被阻止并显示白屏。我创建了一个间歇性的不可见表单并将数据从我的域发布到流中,然后继续相同的步骤,这已经解决了问题。发布解决方案以防任何人在“使用 Apple 登录”流程中遇到相同问题。


推荐阅读