how to remove logout and loggedout paged from asp.net identityserver3

房东的猫 提交于 2019-12-11 06:18:44

问题


I just want a simple single sign-on for my application and identityserver3 seen to be a good solution. three things i didn't like about it though the consent page, the logout and logged out pages. i manage to disable the consent page by setting these lines to the Clients.cs file

RequireConsent = false,
AllowRememberConsent = false,

i also added custom view following the docs on Custom View Service.

so now How do I disable the logout and loggedout pages so that it automatically send the user to the home page when they clicks the sign out button?


回答1:


The documentation here will help you. You are interested in specifying a custom set of AuthenticationOptions. Within that, there are three properties of interest:

  1. EnableSignOutPrompt

    Indicates whether IdentityServer will show a confirmation page for sign-out. When a client initiates a sign-out, by default IdentityServer will ask the user for confirmation. This is a mitigation technique against “logout spam”. Defaults to true.

  2. EnablePostSignOutAutoRedirect

    Gets or sets a value indicating whether IdentityServer automatically redirects back to a validated post_logout_redirect_uri passed to the signout endpoint. Defaults to false.

  3. PostSignOutAutoRedirectDelay

    Gets or sets the delay (in seconds) before redirecting to a post_logout_redirect_uri. Defaults to 0.

Using these three settings you should be able to tweak IdentityServer3 to your liking.

For example, your Startup.cs may look like this:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/identity", idsrvApp =>
        {
            idsrvApp.UseIdentityServer(new IdentityServerOptions
            {
                AuthenticationOptions = new AuthenticationOptions()
                {
                    EnableSignOutPrompt = false,
                    EnablePostSignOutAutoRedirect = true,
                    PostSignOutAutoRedirectDelay = 0
                },
                EnableWelcomePage = false,
                Factory = Factory.Get(),
                SigningCertificate = Certificate.Get(),
                SiteName = "Identity Server Example"
            });
        });
    }
}


来源:https://stackoverflow.com/questions/38907376/how-to-remove-logout-and-loggedout-paged-from-asp-net-identityserver3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!