简体   繁体   中英

IdentityServer4 Configuration Issue

I am adding IdentityServer4 to an .net core 2.1 app and am having issues with signing out and it is making thing that I have an overall structure issue.

From all examples I can find Clients have a different RedirectUris and PostLogoutRedirectUris port than what their options.Authority is.

For example my cleints are:

public static IEnumerable<Client> GetClients()
    {
        return new List<Client> {
            new Client {
                ClientId = "oauthClient",
                ClientName = "Example Client Credentials Client Application",
                AllowedGrantTypes = GrantTypes.ClientCredentials,
                ClientSecrets = new List<Secret> {
                        new Secret("superSecretPassword".Sha256())},
                    AllowedScopes = new List<string> {"customAPI.read"}
                },
            new Client {
                ClientId = "openIdConnectClient",
                ClientName = "Example Implicit Client Application",
                AllowedGrantTypes = GrantTypes.Implicit,
                AllowedScopes = new List<string>
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    IdentityServerConstants.StandardScopes.Email,
                    "role",
                    "customAPI.write"
                },
                RedirectUris = new List<string> {"http://localhost:5000/signin-oidc"},
                PostLogoutRedirectUris = new List<string> {"http://localhost:5000"}
            }
        };
    }

and my IdentityServer is set up as

services.AddAuthentication(options =>
            {
                options.DefaultScheme = "cookie";
                options.DefaultChallengeScheme = "oidc";
            })
            .AddCookie("cookie")
            .AddOpenIdConnect("oidc", options =>
            {
                options.RequireHttpsMetadata = false;
                options.Authority = "http://localhost:5000/";
                options.ClientId = "openIdConnectClient";
                options.SignInScheme = "cookie";
            });

think this is wrong but I am not sure, when I set options.Authority = "http://localhost:5001/"; which is what I think I should do from my examples I get an exception.

This may be a dumb question but can I use IdentityServer4 with only 1 host, or do I need two?

I'm having a little trouble understanding your question, but I'll try to answer to the best of my ability.

You can configure identity server and the project your using with identity server on the same host.

That being said, it really depends on what your intent is. For example, should the identity server be available if the client application is down?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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