Sadly the OWIN middleware is not supporting HttpPost sign-out actions.
As a workaround, you can manually post the necessary parameter to the end session endpoint
I provide a link in my MVC5 application, so that a user is able to logout:
@{
Claim idTokenHintClaim = Request.GetOwinContext().Authentication.User.FindFirst("id_token");
string idTokenHint = idTokenHintClaim != null
? idTokenHintClaim.Value
: null;
}
<form action="https://.../core/endsession" method="POST" id="logoutForm">
<input type="hidden" name="id_token_hint" value="@idTokenHint"/>
<input type="hidden" name="post_logout_redirect_uri" value="@PostLogoutRedirectUrl"/>
</form>
<a href="javascript:document.getElementById('logoutForm').submit()">
Logout
</a>
The IdentityServer3 is doing its job and destroys the current user session. After that IdentityServer3 is calling our @PostLogoutRedirectUrl
. The @PostLogoutRedirectUrl
is pointing to an controller method of the MVC application:
public ActionResult LogoutCallback()
{
HttpCookie cookie = new HttpCookie("SecureCookieName");
cookie.HttpOnly = true;
cookie.Expires = new DateTime(1999, 10, 12);
Response.Cookies.Remove("SecureCookieName");
Response.Cookies.Add(cookie);
SetPasswordResetHint();
return RedirectToAction("Index");
}
I hope the support for HttpPost methods will be added in the OWIN middleware soon.