public static void ConfigureServices(IServiceCollection services, AuthConfiguration authConfiguration) { if (authConfiguration?.IsEnabled == true) { services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.Authority = authConfiguration.Authority; options.Audience = authConfiguration.Audience; // If the access token does not have a `sub` claim, `User.Identity.Name` will be `null`. Map it to a different claim by setting the NameClaimType below. options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = ClaimTypes.NameIdentifier }; //options.TokenValidationParameters = new TokenValidationParameters //{ // ValidIssuers = new[] // { // authConfiguration.Authority + "/v2.0" // }, // ValidAudiences = new[] // { // authConfiguration.Authority + "/resources", // authConfiguration.Application // }, //}; #if DEBUG options.RequireHttpsMetadata = false; options.IncludeErrorDetails = true; options.Events = new JwtBearerEvents { OnAuthenticationFailed = AuthenticationFailed }; #endif }); } }
public static void Configure(IApplicationBuilder app, AuthConfiguration authConfiguration) { }