添加jwt认证模块
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AspNetCore.Microsoft.AspNetCore.Hosting;
|
||||
using Yi.Framework.Authentication.JwtBearer;
|
||||
using Yi.Framework.Core.Autofac.Extensions;
|
||||
using Yi.Framework.Core.Autofac.Modules;
|
||||
using Yi.Framework.Core.Extensions;
|
||||
@@ -13,6 +14,12 @@ builder.WebHost.UseStartUrlsServer(builder.Configuration);
|
||||
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.UseYiModules(typeof(YiFrameworkWebModule));
|
||||
|
||||
builder.Services.AddAuthentication(YiJwtAuthenticationHandler.YiJwtSchemeName);
|
||||
|
||||
builder.Services.AddAuthentication(option =>
|
||||
{
|
||||
option.AddScheme<YiJwtAuthenticationHandler>(YiJwtAuthenticationHandler.YiJwtSchemeName, YiJwtAuthenticationHandler.YiJwtSchemeName);
|
||||
});
|
||||
//<2F><><EFBFBD><EFBFBD>autofacģ<63><C4A3>,<2C><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
||||
builder.Host.ConfigureAutoFacContainer(container =>
|
||||
{
|
||||
@@ -25,6 +32,9 @@ var t = app.Services.GetService<Test2Entity>();
|
||||
|
||||
//ȫ<>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
app.UseErrorHandlingServer();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user