IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

IdentityServer and Resource Server running as the same service

Open AlexanderBosshard opened this issue 8 years ago • 2 comments

I have a setup where my identity server and resource server are running on the same service.

If I don't run both in the same service, everything works fine.

 services.AddIdentityServer(options =>
                {
                    options.UserInteraction.LoginUrl = appSettings.DomainNameWithProtocol + RELATIVE_LOGIN_PATH;
                    options.UserInteraction.LogoutUrl = appSettings.DomainNameWithProtocol + RELATIVE_LOGOUT_PATH;
                })
                .AddDeveloperSigningCredential()
                .AddAspNetIdentity<ApplicationUser>()
                .AddConfigurationStore(options =>
                {
                    options.ConfigureDbContext = builder =>
                        builder.UseSqlServer(connectionString,
                            sql => sql.MigrationsAssembly(migrationsAssembly));
                })
                .AddOperationalStore(options =>
                {
                    options.ConfigureDbContext = builder =>
                        builder.UseSqlServer(connectionString,
                            sql => sql.MigrationsAssembly(migrationsAssembly));

                    options.EnableTokenCleanup = true;
                    options.TokenCleanupInterval = 30;
                });

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
               .AddIdentityServerAuthentication(options =>
               {
                   options.Authority = "https://localhost:44287"
                   options.RequireHttpsMetadata = true;
                   options.ApiName = "userserviceapi";
                   options.ApiSecret = "AA3FF159-3CC0-4894-B2D7-764BA00A584A";
               });

Within the authorization policy (context variable) it doesn't resolve any of the claims for the user.

            services.AddAuthorization(options =>
            {
                options.AddPolicy("MyPolicyName", policy =>
                    policy.RequireAssertion(context =>
                        context.User.HasClaim(c =>
                            c.Issuer == AUTHORITY_ISSUER_NAME &&
                            c.Value == "ExpectedValue")));
            });

image

As soon as I go to my other service and use the exact same ApiName and ApiSecret then everything works fine! Could there be any issues when the resource service tries to call itself to verify the access token?

image

Thanks in advance.

AlexanderBosshard avatar Jul 27 '18 19:07 AlexanderBosshard

Sounds similar to this question: https://github.com/IdentityServer/IdentityServer4/issues/2495 Here's some info: https://github.com/IdentityServer/IdentityServer4/issues/2495#issuecomment-409237830

brockallen avatar Jul 31 '18 14:07 brockallen

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 13 '20 04:01 lock[bot]