【发布时间】:2020-04-10 08:44:48
【问题描述】:
我和https://github.com/IdentityServer/IdentityServer4/issues/3153有类似的问题
我正在使用 Asp Net Identity 和 EF Core 组合示例,除了我尝试从 IS 页面注销时,一切正常,数据库、种子、api 调用。它不会删除.AspNetCore.Cookies,它是保持用户在客户端登录的那个。
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout(LogoutInputModel model)
{
// build a model so the logged out page knows what to display
var vm = await BuildLoggedOutViewModelAsync(model.LogoutId);
if (User?.Identity.IsAuthenticated == true)
{
_log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + "Logout: User Is Authenticated" + "</AUDIT>");
try
{
await _signInManager.SignOutAsync();
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
// raise the logout event
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
}
catch (NotSupportedException)
{
_log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + "Logout: SignOutAsync Not Supported" + "</AUDIT>");
}
}
/* https://github.com/IdentityServer/IdentityServer4/issues/855 */
// check if we need to trigger sign-out at an upstream identity provider
// delete local authentication cookie
Response.Cookies.Delete(".AspNetCore.Identity.Application");
Response.Cookies.Delete("idserv.external");
Response.Cookies.Delete("idserv.session");
_log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + "Logout: Trigger external signout " + vm.TriggerExternalSignout + "</AUDIT>");
if (vm.TriggerExternalSignout)
{
// build a return URL so the upstream provider will redirect back
// to us after the user has logged out. this allows us to then
// complete our single sign-out processing.
string url = Url.Action("Logout", new { logoutId = vm.LogoutId });
//url = _configuration["AppSettings:PostLogoutRedirectUri"];
url = vm.PostLogoutRedirectUri;
//url = "redirect.html";
// this triggers a redirect to the external provider for sign-out
_log.LogCustomInfo(LoggingType.Information, "<AUDIT>" + "Logout: Redirect to " + url + "</AUDIT>");
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}
return View("LoggedOut", vm);
}
我在 Angular 客户端和 MVC 应用程序中遇到了同样的问题。
如果我手动删除.AspNetCore.Identity.Application,客户端将被注销。我正在使用keycloak 进行身份验证并使用
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.SignOutScheme = IdentityServerConstants.SignoutScheme;
在启动IS配置选项中。
【问题讨论】:
标签: angular security .net-core identityserver4