IdentityServer4 IsValidReturnUrl returns false for a valid URL

I have a test project with this client configuration:

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

When I try to check it in LoginController, I get the result false(this is from the Immediate window:

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

Also the this.identityServer.GetAuthorizationContextAsync(returnUrl)result null. Am I doing something wrong?

+4
source share
1 answer

Yes - you need to add one RedirectUri when you configure your client, which is one of RedirectUris, which is in the list that you have above.

Sort of #

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

Source: https://habr.com/ru/post/1674653/


All Articles