IdentityServer3注销未重定向到源

时间:2016-09-09 10:32:36

标签: oauth oauth-2.0 identityserver3 openid-connect thinktecture-ident-server

我从身份服务器登出MVC,但它不会自动重定向。我甚至没有得到"点击此处返回"通常默认显示。

这是我的设置。

idsvr中的

: 工厂是使用EF的Aspnet标识(主要是开箱即用的实现)

IdentityServerOptions {
AuthenticationOptions =
    {
        EnablePostSignOutAutoRedirect = true,
        SignInMessageThreshold = 3,
        EnableSignOutPrompt = false
    }
}

在MVC中

app.UseOpenIdConnectAuthentication (new OpenIdConnectAuthenticationOptions
{
PostLogoutRedirectUri = "https://localhost:port",
RedirectUri = "https://localhost:port",
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenValidated = HereIGetRefreshTokenEtc(),
RedirectToIdentityProvider =  n =>
{
    if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
    {
        var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
        if (idTokenHint != null)
        {
            n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
        }
    }
    return Task.FromResult(0);
}
}
});

Logout Controller操作就像这样

    public ActionResult Logout()
    {
        //Option 1 : because I have already provided redirect URI in initial configuration
        Request.GetOwinContext().Authentication.SignOut();

        //Option 2: Because option 1 did not work
        Request.GetOwinContext().Authentication.SignOut(new AuthenticationProperties { RedirectUri = "https://mymvc.site" });

        //none of the return statements work. (obviously i have tried them individually)

        return RedirectToAction("Index", "Home", new{ area = ""});
        return Redirect("https://idsvr/connect/endsession");
    }

我错过了什么?

1 个答案:

答案 0 :(得分:2)

知道了! 我错过了在客户端配置中的PostLogoutRedirectUris中添加链接。它正在saying"无效的帖子注销URI"。