Identityserver4: how can I config authority with subdomains

Created on 26 Sep 2020  路  2Comments  路  Source: IdentityServer/IdentityServer4

My IdentityServer and ApiResource in the same project, and develop in sub domain like

  • a.myids.com
  • b.myids.com
  • c.myids.com
  • d.myids.com

I have reference this code, but only can config one IdentityServer address, how can I change the Authority property dynamic, follow current requestContext Uri?

{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                // base-address of your identityserver
                options.Authority = "https://demo.identityserver.io";

                // if you are using API resources, you can specify the name here
                options.Audience = "resource1";

                // IdentityServer emits a typ header by default, recommended extra check
                options.TokenValidationParameters.ValidTypes = new[] { "at+jwt" };
            });
    }
}
question

Most helpful comment

These options must have a TokenValidationParameters property of type TokenValidationParameters which has a property named IssuerValidator where you can put your own validation delegate. Also there is ValidIssuers property where you can put a list of all valid issuers. You can check everything here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.tokens.tokenvalidationparameters?view=azure-dotnet .

All 2 comments

These options must have a TokenValidationParameters property of type TokenValidationParameters which has a property named IssuerValidator where you can put your own validation delegate. Also there is ValidIssuers property where you can put a list of all valid issuers. You can check everything here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.tokens.tokenvalidationparameters?view=azure-dotnet .

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

Was this page helpful?
0 / 5 - 0 ratings