【问题标题】:IdentityServer4 IsValidReturnUrl returns false for valid urlIdentityServer4 IsValidReturnUrl 为有效 url 返回 false
【发布时间】:2019-05-01 03:55:45
【问题描述】:

我有一个使用此客户端配置的测试项目:

public class Clients : IClientStore
    {
        public Task<Client> FindClientByIdAsync(string clientId)
        {
            return Task.FromResult(new Client
            {
                ClientId = "client.webforms",
                ClientName = "WebForms Client",
                AllowedGrantTypes = GrantTypes.Hybrid,
                AllowAccessTokensViaBrowser = false,

                ClientSecrets =
                    {
                        new Secret("1234".Sha256())
                    },

                RedirectUris = { "http://localhost:9869/signin-oidc" },
                PostLogoutRedirectUris = { "http://localhost:9869/" },

                AllowedScopes =
                    {
                        IdentityServerConstants.StandardScopes.OpenId,
                        CstIdSrvScopeTypes.TestWebForms
                    },
                AllowOfflineAccess = false,
                RequireConsent = false,

                AlwaysIncludeUserClaimsInIdToken = true
            });
        }
    }

当我尝试在 LoginController 中验证它时,我得到了 false 结果(这是来自即时窗口:

returnUrl
"http://localhost:9869/signin-oidc"
this.identityServer.IsValidReturnUrl(returnUrl)
false

同样this.identityServer.GetAuthorizationContextAsync(returnUrl) 结果是null。我做错了吗?

【问题讨论】:

  • 遇到同样的问题
  • 您找到解决方案了吗?我自己的returnUrl 是有效的,存在于我的数据存储中,并且正在从客户端通过网络发送。
  • 正如该问题所暗示的,如果您尝试将登录 UI 放在与身份服务器逻辑不同的网站上,则它尚未完全实现。您现在可以删除IsValidReturnUrl 检查,但我觉得其他事情最终会中断
  • 我相信@Yes 是正确的。不要将这里发生的事情与应该从外部客户端发生的正确、有效的重定向混淆。如果设置正确,GetAuthorizationContextAsync 调用将返回非空结果。它会查找已在 IdentityServer4 中配置的 URI,因此 ~//Login 等 URL 可能不起作用(除非已配置)。
  • @DanielL,你想要什么并不完全清楚。未解决的问题仅涉及 IdSrv 的 UI,它位于 IdSrv 以外的其他主机上。您的大部分(和最初的)问题都是指“只是一个客户端”,这是一个完全不同的故事——如果配置正确——只会根据 oidc 规范工作。

标签: identityserver4


【解决方案1】:

是的 - 当您配置您的客户端时,您需要添加一个 RedirectUri,它是您上面列表中的 RedirectUris 之一。

类似的东西 #

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            SignInAsAuthenticationType = Settings.AuthenticationType,
            Authority = config.Authority,
            RedirectUri = config.RedirectUri
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-24
    • 1970-01-01
    • 2016-01-14
    • 1970-01-01
    • 1970-01-01
    • 2011-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多