I have two cookies in my browser put there by the IDS4 during sign-in. I need to remove them. Failing to get rid of them by signing out (for whatever reason that may be, despite the docs), I decided to apply a pramatic work-around and remove them manually. It seems those a hard cookie. Two of them...
I attempted to get rid of them like this - targetting all the available schemas as suggested.
await HttpContext.SignOutAsync("Identity.Application");
await HttpContext.SignOutAsync("Identity.External");
await HttpContext.SignOutAsync("Identity.TwoFactorRememberMe");
await HttpContext.SignOutAsync("Identity.TwoFactorUserId");
await HttpContext.SignOutAsync("idsrv");
await HttpContext.SignOutAsync("idsrv.external");
I tried to kill them by explicit hit as proposed here. Apparently, though, that's not how the cookie crumbles.
Response.Cookies.Delete(".AspNetCore.Identity.Application");
Response.Cookies.Delete("idsrv.session");
Nothing of that erases them. They do disappear when I restart the browser, of course, but I need them gone without that measure (also, if I'm to restart the browser, I don't need to log the user out as they will be gone anyway).
I've seen suggestions to call HttpContext.Current
but that the same as just simply HttpContext
in my controller (according to this). There is talk about Session.Abandon
but I don't see that field in my context. There seems to be some issues with this specific matter but I can't tell if those still remain unsolved by the IDS4 team.
edit
public async Task<IActionResult> LogOut([FromQuery] string logoutId)
{
LogoutRequest context = await InteractionService.GetLogoutContextAsync(logoutId);
bool? isLoggedIn = User?.Identity.IsAuthenticated;
isLoggedIn |= User.IsAuthenticated();
await HttpContext.SignOutAsync();
await HttpContext.SignOutAsync(IdentityConstants.ApplicationScheme);
await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);
//Response.Cookies.Delete("idsrv.session");
var output = new
{
authenticated = isLoggedIn,
clientId = context.ClientId,
sessionId = context.SessionId,
redirect = context.PostLogoutRedirectUri,
sub = context.SubjectId
};
return Ok(output);
// return SignOut();
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…