IdentityServer and Resource Server running as the same service
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")));
});

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?

Thanks in advance.
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
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.