IdentityServer4 IsValidReturnUrl对于有效的URL返回false

dst*_*str 8 identityserver4

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

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
            });
        }
    }
Run Code Online (Sandbox Code Playgroud)

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

returnUrl
"http://localhost:9869/signin-oidc"
this.identityServer.IsValidReturnUrl(returnUrl)
false
Run Code Online (Sandbox Code Playgroud)

此外this.identityServer.GetAuthorizationContextAsync(returnUrl)结果null。难道我做错了什么?

mon*_*mps 3

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

就像是 #

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            SignInAsAuthenticationType = Settings.AuthenticationType,
            Authority = config.Authority,
            RedirectUri = config.RedirectUri
        }
Run Code Online (Sandbox Code Playgroud)