fix:auth
This commit is contained in:
parent
da257affae
commit
d30375ba49
@ -10,7 +10,9 @@ using Fake.AspNetCore.Swagger;
|
||||
using Fake.FeiShu;
|
||||
using Fake.Security.Claims;
|
||||
using Fake.Serilog;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Mvc.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oms.Application;
|
||||
using Oms.SqlSugarCore;
|
||||
@ -115,6 +117,17 @@ public class SimpleAdminApiModule : FakeModule
|
||||
services.AddTransient<IException2ResponseConverter>(sp =>
|
||||
new ExceptionHandling.OmsException2ResponseConverter(
|
||||
sp.GetRequiredService<DefaultException2ResponseConverter>()));
|
||||
|
||||
// 全局授权配置:所有接口默认需要授权
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder()
|
||||
.RequireAuthenticatedUser()
|
||||
.Build();
|
||||
options.Filters.Add(new AuthorizeFilter(policy));
|
||||
});
|
||||
// 添加授权服务
|
||||
services.AddAuthorization();
|
||||
}
|
||||
|
||||
public override void ConfigureApplication(ApplicationConfigureContext context)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user