identityserver4 关联失败
identityserver4 Correlation failed
最近在学习idenetty server 4,组织了一个test project in github
环境:windows10,边缘
边缘:Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如 Gecko)Chrome/88.0.4324.96 Safari/537。 36Edg/88.0.705.56
services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
// 添加可以处理cookie的处理程序
.AddCookie("Cookies")
// 用于配置执行OpenID Connect协议的处理程序
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://demo.identityserver.io/"; // 受信任令牌服务地址
options.RequireHttpsMetadata = true;
options.ClientId = "interactive.confidential";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.SaveTokens = true; // 用于将来自IdentityServer的令牌保留在cookie中
// 1、添加授权访问api的支持
//options.Scope.Add("scope1");
options.Scope.Add("email");
//options.Scope.Add("profile");
options.GetClaimsFromUserInfoEndpoint = true;
//options.Scope.Add("offline_access");
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
};
});
问题是我登录授权成功了,但是回跳的时候会出现如下错误
Exception: Correlation failed.
Unknown location
Exception: An error was encountered while handling the remote login.
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler<TOptions>.HandleRequestAsync()
之后看到一些关于cookie的问题。我加了一个ConfigureNonBreakingSameSiteCookies
,还是不行
当我禁用边缘配置时 Cookies without SameSite must be secure
,它成功了。
问题是Is there any other way?
如果有人能就此提供一些见解,我将不胜感激。
根据上述评论,这可能是因为您没有使用 HTTPS。该关联 cookie 将设置为 SameSite=None
或 SameSite=Lax
,因为它需要在另一台主机发起的请求期间可以访问,并且 Chrome 如果不是由 HTTPS 发出,Edge 将默认阻止它来源.
最近在学习idenetty server 4,组织了一个test project in github
环境:windows10,边缘 边缘:Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如 Gecko)Chrome/88.0.4324.96 Safari/537。 36Edg/88.0.705.56
services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
// 添加可以处理cookie的处理程序
.AddCookie("Cookies")
// 用于配置执行OpenID Connect协议的处理程序
.AddOpenIdConnect("oidc", options =>
{
options.Authority = "https://demo.identityserver.io/"; // 受信任令牌服务地址
options.RequireHttpsMetadata = true;
options.ClientId = "interactive.confidential";
options.ClientSecret = "secret";
options.ResponseType = "code";
options.SaveTokens = true; // 用于将来自IdentityServer的令牌保留在cookie中
// 1、添加授权访问api的支持
//options.Scope.Add("scope1");
options.Scope.Add("email");
//options.Scope.Add("profile");
options.GetClaimsFromUserInfoEndpoint = true;
//options.Scope.Add("offline_access");
options.TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
};
});
问题是我登录授权成功了,但是回跳的时候会出现如下错误
Exception: Correlation failed.
Unknown location
Exception: An error was encountered while handling the remote login.
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler<TOptions>.HandleRequestAsync()
之后看到一些关于cookie的问题。我加了一个ConfigureNonBreakingSameSiteCookies
,还是不行
当我禁用边缘配置时 Cookies without SameSite must be secure
,它成功了。
问题是Is there any other way?
如果有人能就此提供一些见解,我将不胜感激。
根据上述评论,这可能是因为您没有使用 HTTPS。该关联 cookie 将设置为 SameSite=None
或 SameSite=Lax
,因为它需要在另一台主机发起的请求期间可以访问,并且 Chrome 如果不是由 HTTPS 发出,Edge 将默认阻止它来源.