在我的Blazor应用程序中,我使用身份服务器(identityserver.io)作为外部服务来管理授权。
登录工作正常,但当我尝试注销,然后尝试登录时,我直接登录,而不要求任何用户名/密码!我已经找了一个星期了,没有找到任何解决方案!
我使用以下代码:
var props = (returnUrl is null) ? null : new AuthenticationProperties()
{
RedirectUri = returnUrl
};
await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("oidc", props);我也试着删除所有的cookie,但HttpContext.Request.Cookies没有cookie!
我还检查了以下链接:https://mcguirev10.com/2018/01/26/signoutasync-and-identity-server-cookies.html,但我没有看到任何有帮助的东西!
仅供参考,下面是我如何设置的:
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
//options.Cookie.Name = ".MyApp";
})
.AddOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = true;
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("MyApp");
options.ClaimActions.MapAbpClaimTypes();
});
}发布于 2019-12-30 15:11:17
要通过单击链接Click here to return to the Interactive client ....从IDS4注销后重定向回客户端应用程序,您应该在客户端配置中设置正确的PostLogoutRedirectUris:
new Client
{
....
// where to redirect to after logout
PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },
....
}, 在@McGuireV10的文章中,他使用身份服务器的演示服务器进行测试,并且使用interactive.confidential.short客户端,您不能设置该客户端的PostLogoutRedirectUris,因此它将默认为https://localhost:5001/signout-callback-oidc。您可以设置自己的身份服务器来测试该方案。
发布于 2022-01-19 18:28:40
对于SignOut,您可以尝试这种方式。应该能行得通。
public class LogoutModel : PageModel
{
public async Task<IActionResult> OnGetAsync()
{
return SignOut(
new AuthenticationProperties
{
RedirectUri = "/"
},
OpenIdConnectDefaults.AuthenticationScheme,
CookieAuthenticationDefaults.AuthenticationScheme);
}
}https://stackoverflow.com/questions/59486045
复制相似问题