|
@@ -53,8 +53,8 @@ builder.Services.AddControllers()
|
|
|
//options.JsonSerializerOptions.Converters.Add(new JsonConverterDecimal(0.0000M));
|
|
|
});
|
|
|
|
|
|
-// 添加授权服务
|
|
|
-builder.Services.AddMyJWTBearerAuth();
|
|
|
+//// 添加授权服务
|
|
|
+//builder.Services.AddMyJWTBearerAuth();
|
|
|
|
|
|
#region Cors
|
|
|
builder.Services.AddCors(policy =>
|
|
@@ -211,23 +211,23 @@ if (AppSettingsHelper.Get("UseSwagger").ToBool())
|
|
|
|
|
|
#region 添加校验
|
|
|
|
|
|
-//builder.Services.AddTransient<OASystemAuthentication>();
|
|
|
-//builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
|
-// .AddJwtBearer(options =>
|
|
|
-// {
|
|
|
-// options.TokenValidationParameters = new TokenValidationParameters
|
|
|
-// {
|
|
|
-// ValidateIssuer = true,
|
|
|
-// ValidateAudience = true,
|
|
|
-// ValidateLifetime = true,
|
|
|
-// ValidateIssuerSigningKey = true,
|
|
|
-// ValidAudience = "OASystem.com",
|
|
|
-// ValidIssuer = "OASystem.com",
|
|
|
-// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"])),
|
|
|
-// ClockSkew = TimeSpan.FromSeconds(30), //过期时间容错值,解决服务器端时间不同步问题(秒)
|
|
|
-// RequireExpirationTime = true,
|
|
|
-// };
|
|
|
-// });
|
|
|
+builder.Services.AddTransient<OASystemAuthentication>();
|
|
|
+builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
|
+ .AddJwtBearer(options =>
|
|
|
+ {
|
|
|
+ options.TokenValidationParameters = new TokenValidationParameters
|
|
|
+ {
|
|
|
+ ValidateIssuer = true,
|
|
|
+ ValidateAudience = true,
|
|
|
+ ValidateLifetime = true,
|
|
|
+ ValidateIssuerSigningKey = true,
|
|
|
+ ValidAudience = "OASystem.com",
|
|
|
+ ValidIssuer = "OASystem.com",
|
|
|
+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_config["JwtSecurityKey"])),
|
|
|
+ ClockSkew = TimeSpan.FromSeconds(30), //过期时间容错值,解决服务器端时间不同步问题(秒)
|
|
|
+ RequireExpirationTime = true,
|
|
|
+ };
|
|
|
+ });
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化日志
|
|
@@ -322,7 +322,7 @@ app.UseAuthentication(); //
|
|
|
app.UseAuthorization(); // 授权
|
|
|
|
|
|
// 授权路径
|
|
|
-app.MapGet("generatetoken", c => c.Response.WriteAsync(JWTBearer.GenerateToken(c)));
|
|
|
+//app.MapGet("generatetoken", c => c.Response.WriteAsync(JWTBearer.GenerateToken(c)));
|
|
|
|
|
|
#region 启用swaggerUI
|
|
|
if (AppSettingsHelper.Get("UseSwagger").ToBool())
|