添加jwt认证模块
This commit is contained in:
@@ -15,6 +15,7 @@ using Yi.Framework.Domain.Student.Entities;
|
||||
using Yi.Framework.Ddd.Services;
|
||||
using Yi.Framework.Core.Attributes;
|
||||
using Yi.Framework.Uow;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Yi.Framework.Application.Student
|
||||
{
|
||||
@@ -41,6 +42,7 @@ namespace Yi.Framework.Application.Student
|
||||
/// Uow
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Authorize]
|
||||
public async Task<StudentGetOutputDto> PostUow()
|
||||
{
|
||||
StudentGetOutputDto res = new();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -33,3 +33,6 @@
|
||||
2023:01:17-23:24:07本次运行启动时间为:1836毫秒
|
||||
2023:01:17-23:29:20本次运行启动时间为:1958毫秒
|
||||
2023:01:17-23:45:25本次运行启动时间为:2016毫秒
|
||||
2023:01:18-19:34:47本次运行启动时间为:2631毫秒
|
||||
2023:01:18-19:36:58本次运行启动时间为:2551毫秒
|
||||
2023:01:18-19:40:12本次运行启动时间为:1978毫秒
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Authentication.JwtBearer\Yi.Framework.Authentication.JwtBearer.csproj" />
|
||||
<ProjectReference Include="..\..\src\framework\Yi.Framework.Core.Autofac\Yi.Framework.Core.Autofac.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Application\Yi.Framework.Application.csproj" />
|
||||
<ProjectReference Include="..\Yi.Framework.Sqlsugar\Yi.Framework.Sqlsugar.csproj" />
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user