barteloma
barteloma

Reputation: 6845

IdentityServer directly logout redirection to a page

I have an IdentityServer options to redirect without signout propt.

var options = new IdentityServerOptions    
     {
          // other options ....
          AuthenticationOptions = new AuthenticationOptions
          {
              EnablePostSignOutAutoRedirect = true,
              EnableSignOutPrompt = false, 
          }
     };

When I logout, the system redirects me to an identityserver page that has a message like this "you are logout.". but this page appears very short time and I am redirecting to login page fast. Can I skip this identity server page while logout?

My logout controller like this.

    public ActionResult Logout()
    {
        if (Request.GetOwinContext().Authentication.User.Identity.IsAuthenticated)
        {
            var properties = new AuthenticationProperties
            {
                RedirectUri = "https://localhost:33125/"
            };

            Request.GetOwinContext().Authentication.SignOut(properties);
        }

        return Redirect("/");
    }

Upvotes: 2

Views: 1785

Answers (3)

Martin Staufcik
Martin Staufcik

Reputation: 9490

In IdentityServer4, the Logout method of the AccountController can be modified so that it returns a redirect:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout(LogoutInputModel model)
{
    ...

    return Redirect("http:// client url"); // added

    //return View("LoggedOut", vm); // commented out
}

Yes, it is custom code, it is a quick solution.

Upvotes: 1

CodeReaper
CodeReaper

Reputation: 895

I think you have covered all the steps from the documentation for this part of IdentityServer's configuration. PostSignOutAutoRedirectDelay already is defaulting to 0. So it won't get a quicker redirect back to the origin URL.

I don't think there is a way to skip the page altogether, I'm afraid.

Upvotes: 1

Brock Allen
Brock Allen

Reputation: 7435

Read the docs: https://identityserver.github.io/Documentation/docsv2/configuration/authenticationOptions.html

AuthenticationOptions has a EnablePostSignOutAutoRedirect and a PostSignOutAutoRedirectDelay setting.

Beware if you set this to auto redirect after too short a period of time, your single signout might not be completed to the other apps the user has signed into.

Upvotes: 2

Related Questions