简体   繁体   English

IdentityServer3 将注销重定向到自定义 URL

[英]IdentityServer3 redirect Logout to the Custom URL

I searched in google and Stack Overflow there is no appropriate answer is available.我在 google 和 Stack Overflow 中搜索过,没有合适的答案可用。

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

Once I hit the Logout I'm triggering the following URL : https://localhost:123/core/connect/endsession一旦我点击注销,我就会触发以下 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在 Startup.cs 我有以下代码

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我不知道如何重定向到http://www.google.com而不是以下屏幕

在此处输入图片说明

Kindly assist me...请帮助我...

You need to call the endsession endpoint, passing the id token and post logout redirect url as arguments.您需要调用 endsession 端点,传递 id 令牌和 post logout 重定向 url 作为参数。

/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.其中 {id token} 是调用 /connect/authorize 端点时从身份服务器返回的 id 令牌。

See the docs here https://identityserver.github.io/Documentation/docsv2/endpoints/endSession.html请参阅此处的文档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.请注意,您必须返回一个 id 令牌以使重定向工作,否则 endsession 请求的验证将失败并且不会发生重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM