@@ -144,14 +144,24 @@ builder.Services.AddMasaMinimalAPIs(options =>
|
||||
options.RouteHandlerBuilder= t=> {
|
||||
t.RequireAuthorization()
|
||||
.AddEndpointFilter<LimitUserRequestAuthorizationEndpointFilter>()
|
||||
.AddEndpointFilter<ModelValidationEndpointFilter>()
|
||||
//.AddEndpointFilter<ModelValidationEndpointFilter>()
|
||||
.AddEndpointFilter<UnifiedApiResultEndpointFilter>()
|
||||
.WithGroupName("Institution");
|
||||
.WithGroupName("Institution").DisableAntiforgery();
|
||||
};
|
||||
options.MapHttpMethodsForUnmatched = new string[] { "Post" };
|
||||
options.DisableTrimMethodPrefix = true; //禁用去除方法前缀
|
||||
options.DisableAutoMapRoute = false;//可通过配置true禁用全局自动路由映射或者删除此配置以启用全局自动路由映射
|
||||
});
|
||||
|
||||
//// 添加反伪造服务
|
||||
//builder.Services.AddAntiforgery(options =>
|
||||
//{
|
||||
// // 可选:设置自定义的头部名称以支持 AJAX 请求等
|
||||
// options.HeaderName = "X-XSRF-TOKEN";
|
||||
//});
|
||||
|
||||
//builder.Services.AddAntiforgery();
|
||||
|
||||
#endregion
|
||||
|
||||
var app = builder.Build();
|
||||
@@ -160,7 +170,6 @@ var env = app.Environment;
|
||||
#region 配置中间件
|
||||
|
||||
|
||||
|
||||
app.UseMiddleware<EncryptionRequestMiddleware>();
|
||||
|
||||
#region 异常处理 全局业务异常已统一处理了,非业务错误会来到这里 400 -500状态码
|
||||
@@ -235,6 +244,13 @@ app.UseRouting();
|
||||
app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
//Map MinimalAPI routes
|
||||
app.MapMasaMinimalAPIs();
|
||||
|
||||
//// 这里添加反伪造中间件
|
||||
//app.UseAntiforgery();
|
||||
app.MapControllers();
|
||||
|
||||
app.MapHub<UploadHub>("/UploadHub");
|
||||
@@ -244,8 +260,7 @@ app.MapHealthChecks("/health");
|
||||
|
||||
#endregion
|
||||
|
||||
//Map MinimalAPI routes
|
||||
app.MapMasaMinimalAPIs();
|
||||
|
||||
|
||||
// Serilog
|
||||
SerilogExtension.AddSerilogSetup(enviromentName, app.Services);
|
||||
|
||||
Reference in New Issue
Block a user