// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var authOptions = new FunkmapJwtOptions(Configuration); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters() { ValidateAudience = true, ValidateIssuer = true, ValidateIssuerSigningKey = true, ValidateLifetime = true, ValidIssuer = authOptions.Issuer, ValidAudience = authOptions.Audience, IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(authOptions.Key)) }; }); services.AddDataServices(Configuration); services.AddCors(); services.AddMvc(); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = "Funkmap Payments API", Version = "v1" }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); options.IncludeXmlComments(xmlPath); options.AddSecurityDefinition("Bearer", new OAuth2Scheme { Flow = "password", TokenUrl = authOptions.TokenUrl, }); options.DocumentFilter <OAuthDocumentFilter>(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var authOptions = new FunkmapJwtOptions(Configuration); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters() { ValidateAudience = true, ValidateIssuer = true, ValidateIssuerSigningKey = true, ValidateLifetime = true, ValidIssuer = authOptions.Issuer, ValidAudience = authOptions.Audience, IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(authOptions.Key)) }; }); services.AddMvc(); }