IdentityServer3 redirect Logout to the Custom URL

房东的猫 提交于 2019-12-11 05:09:15

问题


I searched in google and Stack Overflow there is no appropriate answer is available.

I'm using ReactJs + Redux in the Client Application, .Net WebAPI is used for contacting the Database and other logical implementation and Finally I'm using IdentityServer3 for authenticating the User.

Once I hit the Logout I'm triggering the following URL : https://localhost:123/core/connect/endsession

new Client
{
    Enabled = true,
    ClientName = "Super Star Application",
    ClientId = "SS",
    Flow = Flows.Implicit,
    RequireConsent = false,
    RequireSignOutPrompt =false,
    RedirectUris = new List<string>
    {
        "http://localhost:111/callback"
    },
    PostLogoutRedirectUris = new List<string> {"https://www.google.com/"},
    AllowedCorsOrigins = new List<string>
    {
        "http://localhost:111/"
    },
    AllowAccessToAllScopes=true
}

In Startup.cs I'm having the following code

app.Map("/core", core =>
{
    var idSvrFactory = Factory.Configure();
    idSvrFactory.ConfigureUserService("AspId");

    var options = new IdentityServerOptions
    {
        SiteName = "Super Star",
        SigningCertificate = Certificate.Get(),
        Factory = idSvrFactory,
        ProtocolLogoutUrls = new System.Collections.Generic.List<string>()
        {
            "https://www.google.co.in"
        },
        AuthenticationOptions = new AuthenticationOptions
        {
            EnablePostSignOutAutoRedirect=true,
            EnableSignOutPrompt = false,
            PostSignOutAutoRedirectDelay = 1,
            EnableLoginHint = true,
            RememberLastUsername = true,
            EnableAutoCallbackForFederatedSignout = true,
            RequireSignOutPrompt = false
        }
    };

    core.UseIdentityServer(options);
});

I don't know how to redirect to http://www.google.com instead of the following screen

Kindly assist me...


回答1:


You need to call the endsession endpoint, passing the id token and post logout redirect url as arguments.

/connect/endsession?id_token_hint={id token}&post_logout_redirect_uri=http://www.google.com

where {id token} is the id token returned from identity server when calling the /connect/authorize endpoint.

See the docs here https://identityserver.github.io/Documentation/docsv2/endpoints/endSession.html

Note that you MUST send an id token back for the redirect to work, else the validation of the endsession request will fail and no redirect will occur.



来源:https://stackoverflow.com/questions/42670557/identityserver3-redirect-logout-to-the-custom-url

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