// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); string[] issuers = { "https://jerrie.auth0.com/", "https://auth0pnp.auth0.com/" }; var keyResolver = new MultipleIssuerSigningKeyResolver(); services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidAudience = "https://quickstarts/api", ValidIssuers = new List <string>(issuers), IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(securityToken.Issuer, kid) }; }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); string[] issuers = { "https://jerrie.auth0.com/", "https://auth0pnp.auth0.com/" }; var keyResolver = new MultipleIssuerSigningKeyResolver(); var options = new JwtBearerOptions { TokenValidationParameters = new TokenValidationParameters { ValidAudience = "https://rs256.test.api", ValidIssuers = new List <string>(issuers), IssuerSigningKeyResolver = (token, securityToken, kid, parameters) => keyResolver.GetSigningKey(securityToken.Issuer, kid) } }; app.UseJwtBearerAuthentication(options); app.UseMvc(); }