IdentityServer3 redirect Logout to the Custom URL

2019-07-27 22:43发布

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

enter image description here

Kindly assist me...

1条回答
女痞
2楼-- · 2019-07-27 23:00

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.

查看更多
登录 后发表回答