【发布时间】:2020-11-12 12:11:26
【问题描述】:
我正在使用 IdentityServer3,并且我将 ASP.NET Core 作为客户端应用程序。
这是我的 LoggOff 操作方法
[HttpPost]
public async Task LogOff()
{
await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);
await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, OpenIdConnectDefaults.AuthenticationScheme);
}
当用户注销时,我在提琴手中看到以下重定向
GET /identity/connect/endsession?post_logout_redirect_uri=https%3A%2F%2Flocalhost%3A44352%2Fsignout-callback-oidc&state=XXXXXX&x-client-SKU=XXXXXX&x-client-ver=5.3.0.0 HTTP/1.1
GET /identity/logout?id=XXXXXXXXXX
GET /identity/connect/endsessioncallback?sid=XXXXXXX
最终在浏览器中的 url 设置为 /identity/logout?id=XXXXXXXXXX。这些是身份服务器的 URL,而不是客户端应用程序 URL。
当注销按钮调用LogOff 操作方法时,这将按预期工作。
现在我有一个要求。当用户转到AccessDenied 页面时,我想先注销用户,然后重定向到AccessDenied 视图。 AccessDenied 页面位于 ClientAppliction 中。所以我有另一个调用 SingnOut 并设置 RedirectUri
[HttpGet]
public async Task AccessDenied()
{
await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync(HttpContext, CookieAuthenticationDefaults.AuthenticationScheme);
await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync(HttpContext,
OpenIdConnectDefaults.AuthenticationScheme,
new Microsoft.AspNetCore.Authentication.AuthenticationProperties()
{
RedirectUri = "Account/AccessDenied"
});
}
这不起作用。用户仍然转到identity/logout 而不是AccessDenied。看起来它没有设置注销后重定向 uri。
【问题讨论】:
标签: asp.net-core openid-connect identityserver3