Fix issue with AddAuthentication and no default Schema on Marketing.API

This commit is contained in:
Unai Zorrilla Castro 2017-09-14 18:52:29 +02:00
parent 69b914172f
commit be6e276bff

View File

@ -21,6 +21,7 @@
using Infrastructure.Services; using Infrastructure.Services;
using IntegrationEvents.Events; using IntegrationEvents.Events;
using Marketing.API.IntegrationEvents.Handlers; using Marketing.API.IntegrationEvents.Handlers;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using RabbitMQ.Client; using RabbitMQ.Client;
using Swashbuckle.AspNetCore.Swagger; using Swashbuckle.AspNetCore.Swagger;
@ -199,8 +200,12 @@
// prevent from mapping "sub" claim to nameidentifier. // prevent from mapping "sub" claim to nameidentifier.
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
services.AddAuthentication() services.AddAuthentication(options=>
.AddJwtBearer(options => {
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(options =>
{ {
options.Authority = Configuration.GetValue<string>("IdentityUrl"); options.Authority = Configuration.GetValue<string>("IdentityUrl");
options.Audience = "marketing"; options.Audience = "marketing";