From 92b6270ab23af4c5e7655c5f111fb8838eb0c09b Mon Sep 17 00:00:00 2001 From: yekalkan Date: Fri, 19 Jan 2018 14:40:36 +0300 Subject: [PATCH] Resolved #155 --- .../Startup/AuthConfigurer.cs | 52 ++++++++++--------- .../Startup/Startup.cs | 2 - 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/AuthConfigurer.cs b/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/AuthConfigurer.cs index 183055464..6d24aedc0 100644 --- a/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/AuthConfigurer.cs +++ b/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/AuthConfigurer.cs @@ -16,37 +16,39 @@ public static void Configure(IServiceCollection services, IConfiguration configu { if (bool.Parse(configuration["Authentication:JwtBearer:IsEnabled"])) { - services.AddAuthentication() - .AddJwtBearer(options => - { - options.Audience = configuration["Authentication:JwtBearer:Audience"]; + services.AddAuthentication(options => { + options.DefaultAuthenticateScheme = "JwtBearer"; + options.DefaultChallengeScheme = "JwtBearer"; + }).AddJwtBearer("JwtBearer", options => + { + options.Audience = configuration["Authentication:JwtBearer:Audience"]; - options.TokenValidationParameters = new TokenValidationParameters - { - // The signing key must match! - ValidateIssuerSigningKey = true, - IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(configuration["Authentication:JwtBearer:SecurityKey"])), + options.TokenValidationParameters = new TokenValidationParameters + { + // The signing key must match! + ValidateIssuerSigningKey = true, + IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(configuration["Authentication:JwtBearer:SecurityKey"])), - // Validate the JWT Issuer (iss) claim - ValidateIssuer = true, - ValidIssuer = configuration["Authentication:JwtBearer:Issuer"], + // Validate the JWT Issuer (iss) claim + ValidateIssuer = true, + ValidIssuer = configuration["Authentication:JwtBearer:Issuer"], - // Validate the JWT Audience (aud) claim - ValidateAudience = true, - ValidAudience = configuration["Authentication:JwtBearer:Audience"], + // Validate the JWT Audience (aud) claim + ValidateAudience = true, + ValidAudience = configuration["Authentication:JwtBearer:Audience"], - // Validate the token expiry - ValidateLifetime = true, + // Validate the token expiry + ValidateLifetime = true, - // If you want to allow a certain amount of clock drift, set that here - ClockSkew = TimeSpan.Zero - }; + // If you want to allow a certain amount of clock drift, set that here + ClockSkew = TimeSpan.Zero + }; - options.Events = new JwtBearerEvents - { - OnMessageReceived = QueryStringTokenResolver - }; - }); + options.Events = new JwtBearerEvents + { + OnMessageReceived = QueryStringTokenResolver + }; + }); } } diff --git a/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/Startup.cs b/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/Startup.cs index 3d5664aa4..87e1b35f3 100644 --- a/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/Startup.cs +++ b/aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Host/Startup/Startup.cs @@ -106,8 +106,6 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF app.UseAuthentication(); - app.UseJwtTokenMiddleware(); - app.UseAbpRequestLocalization(); #if FEATURE_SIGNALR