Reputation: 895
I have MVC logging out from identityserver however it does not redirect automatically. I don't even get the "Click here to go back" that is usually displayed by default.
Here is my setup.
in the idsvr: Factory is Aspnet identity using EF (mostly out of the box implementation)
IdentityServerOptions {
AuthenticationOptions =
{
EnablePostSignOutAutoRedirect = true,
SignInMessageThreshold = 3,
EnableSignOutPrompt = false
}
}
in MVC
app.UseOpenIdConnectAuthentication (new OpenIdConnectAuthenticationOptions
{
PostLogoutRedirectUri = "https://localhost:port",
RedirectUri = "https://localhost:port",
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = HereIGetRefreshTokenEtc(),
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
{
var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
if (idTokenHint != null)
{
n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
}
}
return Task.FromResult(0);
}
}
});
The Logout Controller action is like so
public ActionResult Logout()
{
//Option 1 : because I have already provided redirect URI in initial configuration
Request.GetOwinContext().Authentication.SignOut();
//Option 2: Because option 1 did not work
Request.GetOwinContext().Authentication.SignOut(new AuthenticationProperties { RedirectUri = "https://mymvc.site" });
//none of the return statements work. (obviously i have tried them individually)
return RedirectToAction("Index", "Home", new{ area = ""});
return Redirect("https://idsvr/connect/endsession");
}
What am I missing?
Upvotes: 0
Views: 1299
Reputation: 895
Got it! I was missing to add the link in the PostLogoutRedirectUris in the Client configuration. It was falling over saying "Invalid post logout URI".
Upvotes: 2