IdentityServer3将注销重定向到自定义URL [英] IdentityServer3 redirect Logout to the Custom URL

查看:140
本文介绍了IdentityServer3将注销重定向到自定义URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google中搜索,并且Stack Overflow没有合适的答案.

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

我在客户端应用程序中使用ReactJs + Redux,.Net WebAPI用于联系数据库和其他逻辑实现,最后我使用IdentityServer3对用户进行身份验证.

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.

点击退出后,我将触发以下URL: https://localhost:123/核心/连接/结束会话

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
}

在Startup.cs中,我有以下代码

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);
});

我不知道如何重定向到 http://www.google.com 而不是重定向到以下屏幕

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

请帮助我...

推荐答案

您需要调用endsession端点,传递id令牌并以注销后的重定向URL作为参数.

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

其中{id token}是调用/connect/authorize端点时从身份服务器返回的id令牌.

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

在此处查看文档 https://identityserver.github.io/Documentation /docsv2/endpoints/endSession.html

请注意,您必须发送回一个ID令牌才能使重定向正常工作,否则结束会话请求的验证将失败并且不会发生重定向.

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.

这篇关于IdentityServer3将注销重定向到自定义URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆