Tar*_*tar 7 c# .net-core auth0 ios12
摘要:iOS/OS 12中的第三方登录中断!
我们有一个适用于多个网站的通用登录.这在Windows,macOS和iOS上的Firefox,Chrome和Safari中运行良好.但是对于iOS 12和macOS 12,似乎cookie不再从auth0登录窗口工作到我们的登录API.
它不仅在Safari中停止工作,而且在iOS 12上也在Chrome和Firefox中停止工作(它仍适用于Mac OS 12上的Chrome).我怀疑这与智能跟踪预防2.0有关,但我很难找到许多技术细节.
我们的登录流程如下:
我在启动时使用以下内容:
services.AddAuthentication(options => {
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.Cookie.Path = "/";
options.SlidingExpiration = false;
})
.AddOpenIdConnect("Auth0", options => {
// Set the authority to your Auth0 domain
options.Authority = $"https://{Configuration["Auth0:Domain"]}";
// Configure the Auth0 Client ID and Client Secret
options.ClientId = Configuration["Auth0:ClientId"];
options.ClientSecret = Configuration["Auth0:ClientSecret"];
// Set response type to code
options.ResponseType = "code";
// Configure the scope
options.Scope.Clear();
options.Scope.Add("openid");
options.Scope.Add("profile");
options.Scope.Add("email");
options.Scope.Add("offline_access");
options.CallbackPath = new PathString("/signin-auth0");
options.ClaimsIssuer = "Auth0";
options.SaveTokens = true;
options.Events = new OpenIdConnectEvents
{
OnRemoteFailure = context => {
<not relevant error redirects>
},
OnRedirectToIdentityProvider = context =>
{
context.ProtocolMessage.SetParameter("audience", $"{ Configuration["Auth0:ApiIdentifier"]}");
return Task.FromResult(0);
},
OnRedirectToIdentityProviderForSignOut = (context) =>
{
<not relevant logout handling>
}
};
});
Run Code Online (Sandbox Code Playgroud)
在登录控制器中,我有一个登录操作,它只设置会话值并调用ChallengeAsync打开Auth0登录:
await HttpContext.ChallengeAsync("Auth0", new AuthenticationProperties() { IsPersistent = true, ExpiresUtc = DateTime.UtcNow.AddMinutes(Global.MAX_LOGIN_DURATION_MINUTES), RedirectUri = returnUri });
Run Code Online (Sandbox Code Playgroud)
"returnUri"参数是返回此同一控制器的完整路径,但操作不同.当这个动作被击中时,来自auth0登录的两个cookie(即https://ourcompany.eu.auth0.com)和我在登录操作中设置的会话数据在iOS 12中丢失.
我能以其他方式在iOS 12上运行吗?所有帮助赞赏.
我终于明白了.默认情况下设置的cookie使用SameSiteMode.Lax.这种方法在iOS 12之前一直运行良好,现在需要设置为iOS 12 SameSiteMode.None.
这是我使用的修改使它再次运行:
.AddCookie(options =>
{
options.Cookie.Path = "/";
options.SlidingExpiration = false;
options.Cookie.SameSite = SameSiteMode.None;
options.Cookie.Expiration = TimeSpan.FromMinutes(Global.MAX_LOGIN_DURATION_MINUTES);
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1722 次 |
| 最近记录: |