大量的代码格式化
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 38s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 38s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s
This commit is contained in:
@@ -22,21 +22,21 @@ builder.Host.UseSerilog((context, loggerConfig) =>
|
||||
});
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers(options =>
|
||||
builder.Services.AddControllers(mvcOptions =>
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
|
||||
.RequireAuthenticatedUser()
|
||||
.Build();
|
||||
|
||||
options.Filters.Add(new AuthorizeFilter(policy));
|
||||
mvcOptions.Filters.Add(new AuthorizeFilter(policy));
|
||||
});
|
||||
builder.Services.AddOpenApi();
|
||||
builder.Services.AddHttpClient();
|
||||
|
||||
// 配置 CORS
|
||||
builder.Services.AddCors(options =>
|
||||
builder.Services.AddCors(corsOptions =>
|
||||
{
|
||||
options.AddDefaultPolicy(policy =>
|
||||
corsOptions.AddDefaultPolicy(policy =>
|
||||
{
|
||||
policy.WithOrigins("http://localhost:5173")
|
||||
.AllowAnyHeader()
|
||||
@@ -55,14 +55,14 @@ var jwtSettings = builder.Configuration.GetSection("JwtSettings");
|
||||
var secretKey = jwtSettings["SecretKey"]!;
|
||||
var key = Encoding.UTF8.GetBytes(secretKey);
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
builder.Services.AddAuthentication(authenticationOptions =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
authenticationOptions.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
authenticationOptions.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
})
|
||||
.AddJwtBearer(options =>
|
||||
.AddJwtBearer(jwtBearerOptions =>
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
@@ -73,7 +73,7 @@ builder.Services.AddAuthentication(options =>
|
||||
IssuerSigningKey = new SymmetricSecurityKey(key),
|
||||
ClockSkew = TimeSpan.Zero
|
||||
};
|
||||
options.Events = new JwtBearerEvents
|
||||
jwtBearerOptions.Events = new JwtBearerEvents
|
||||
{
|
||||
OnChallenge = async context =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user