mirror of https://github.com/abpframework/abp.git
6 changed files with 70 additions and 3 deletions
@ -0,0 +1,25 @@ |
|||
using Microsoft.AspNetCore.Authentication; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
|
|||
namespace Microsoft.AspNetCore.Builder |
|||
{ |
|||
public static class ApplicationBuilderAbpJwtTokenMiddlewareExtension |
|||
{ |
|||
public static IApplicationBuilder UseJwtTokenMiddleware(this IApplicationBuilder app, string schema = JwtBearerDefaults.AuthenticationScheme) |
|||
{ |
|||
return app.Use(async (ctx, next) => |
|||
{ |
|||
if (ctx.User.Identity?.IsAuthenticated != true) |
|||
{ |
|||
var result = await ctx.AuthenticateAsync(schema); |
|||
if (result.Succeeded && result.Principal != null) |
|||
{ |
|||
ctx.User = result.Principal; |
|||
} |
|||
} |
|||
|
|||
await next(); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.AspNetCore.Authentication.JwtBearer</AssemblyName> |
|||
<PackageId>Volo.Abp.AspNetCore.Authentication.JwtBearer</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Security\Volo.Abp.Security.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Security; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Authentication.JwtBearer |
|||
{ |
|||
[DependsOn(typeof(AbpSecurityModule))] |
|||
public class AbpAspNetCoreAuthenticationJwtBearerModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue