Skip to content

Commit

Permalink
Merge pull request #936 from colinin/fix-abp-claims
Browse files Browse the repository at this point in the history
fix(claims): map abp claim types to jwt
  • Loading branch information
colinin committed Apr 23, 2024
2 parents d942c55 + 108e53d commit 94e1bf4
Show file tree
Hide file tree
Showing 43 changed files with 587 additions and 444 deletions.
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: "Build"

on:
push:
branches: [ master ]
paths:
- "**.cs"
- "**.csproj"
Expand Down
3 changes: 2 additions & 1 deletion aspnet-core/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<VoloAbpPackageVersion>8.1.0</VoloAbpPackageVersion>
<VoloAbpLeptonXThemePackageVersion>3.0.0</VoloAbpLeptonXThemePackageVersion>
<VoloAbpLeptonXThemePackageVersion>3.0.5</VoloAbpLeptonXThemePackageVersion>
<LINGYUNAbpPackageVersion>8.1.0</LINGYUNAbpPackageVersion>
<DaprPackageVersion>1.12.0</DaprPackageVersion>
<DistributedLockRedisPackageVersion>1.0.2</DistributedLockRedisPackageVersion>
Expand All @@ -13,6 +13,7 @@
<AgileConfigClientPackageVersion>1.6.9</AgileConfigClientPackageVersion>
<HangfireMySqlStoragePackageVersion>2.0.3</HangfireMySqlStoragePackageVersion>
<HangfireMSSQLStoragePackageVersion>1.8.6</HangfireMSSQLStoragePackageVersion>
<IdentityModelPackageVersion>6.2.0</IdentityModelPackageVersion>
<NESTPackageVersion>7.15.1</NESTPackageVersion>
<NewtonsoftJsonPackageVersion>13.0.1</NewtonsoftJsonPackageVersion>
<OpenTelemetryExtensionsHostingPackageVersion>1.8.0</OpenTelemetryExtensionsHostingPackageVersion>
Expand Down
10 changes: 10 additions & 0 deletions aspnet-core/LINGYUN.MicroService.All.sln
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Dynamic.Queryab
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.DataProtection.Tests", "tests\LINGYUN.Abp.DataProtection.Tests\LINGYUN.Abp.DataProtection.Tests.csproj", "{AAC0C407-B4B9-4E90-99FC-2D793AC229D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "security", "security", "{9D1302BE-3886-49F8-B0CD-35D2AC1E5A37}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Security", "framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj", "{4C71CA88-0D04-4DDB-8906-B953908B8B8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1791,6 +1795,10 @@ Global
{AAC0C407-B4B9-4E90-99FC-2D793AC229D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AAC0C407-B4B9-4E90-99FC-2D793AC229D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AAC0C407-B4B9-4E90-99FC-2D793AC229D9}.Release|Any CPU.Build.0 = Release|Any CPU
{4C71CA88-0D04-4DDB-8906-B953908B8B8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C71CA88-0D04-4DDB-8906-B953908B8B8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C71CA88-0D04-4DDB-8906-B953908B8B8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C71CA88-0D04-4DDB-8906-B953908B8B8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -2131,6 +2139,8 @@ Global
{86E85013-7C71-4770-9323-18897A64F5B2} = {4FAE314C-36CB-4E3F-85B7-41D0A428B37D}
{014A9583-0EAA-48A4-ACBE-07DC88159E13} = {4FAE314C-36CB-4E3F-85B7-41D0A428B37D}
{AAC0C407-B4B9-4E90-99FC-2D793AC229D9} = {370D7CD5-1E17-4F3D-BBFA-03429F6D4F2F}
{9D1302BE-3886-49F8-B0CD-35D2AC1E5A37} = {C5CAD011-DF84-4914-939C-0C029DCEF26F}
{4C71CA88-0D04-4DDB-8906-B953908B8B8B} = {9D1302BE-3886-49F8-B0CD-35D2AC1E5A37}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}
Expand Down
7 changes: 7 additions & 0 deletions aspnet-core/LINGYUN.MicroService.TaskManagement.sln
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.MultiTenancy.Ed
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.HttpOverrides", "framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj", "{088064DD-D141-4E9A-B185-E332920A323A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Security", "framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj", "{BEE1B759-5B65-481B-928B-8BC6A89A7C13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -348,6 +350,10 @@ Global
{088064DD-D141-4E9A-B185-E332920A323A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{088064DD-D141-4E9A-B185-E332920A323A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{088064DD-D141-4E9A-B185-E332920A323A}.Release|Any CPU.Build.0 = Release|Any CPU
{BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEE1B759-5B65-481B-928B-8BC6A89A7C13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -405,6 +411,7 @@ Global
{6E030005-EEA7-480E-9E68-4FC74CFCAF42} = {5A41C31A-B966-418B-B446-5BA1D7E61A62}
{B3E81983-629A-4380-B4C2-50E247916F5E} = {5A41C31A-B966-418B-B446-5BA1D7E61A62}
{088064DD-D141-4E9A-B185-E332920A323A} = {5A41C31A-B966-418B-B446-5BA1D7E61A62}
{BEE1B759-5B65-481B-928B-8BC6A89A7C13} = {5A41C31A-B966-418B-B446-5BA1D7E61A62}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E1FD1F4C-D344-408B-97CF-B6F1F6D7D293}
Expand Down
7 changes: 7 additions & 0 deletions aspnet-core/LINGYUN.MicroService.WebhooksManagement.sln
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{03B4
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.HttpOverrides", "framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj", "{0DFDAC71-BCB9-44CF-A44A-E8288E75246F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Security", "framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj", "{8F11DADB-557A-4ECF-BEBB-19AFA71998A1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -369,6 +371,10 @@ Global
{0DFDAC71-BCB9-44CF-A44A-E8288E75246F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DFDAC71-BCB9-44CF-A44A-E8288E75246F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DFDAC71-BCB9-44CF-A44A-E8288E75246F}.Release|Any CPU.Build.0 = Release|Any CPU
{8F11DADB-557A-4ECF-BEBB-19AFA71998A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F11DADB-557A-4ECF-BEBB-19AFA71998A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F11DADB-557A-4ECF-BEBB-19AFA71998A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F11DADB-557A-4ECF-BEBB-19AFA71998A1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -440,6 +446,7 @@ Global
{5C1E48DE-6247-475B-BDB5-651521AC3A47} = {FB7A9794-06D2-42CF-939E-4626497B97BD}
{004CC7A9-92FF-4E98-8F1D-550D07CB47F0} = {FB7A9794-06D2-42CF-939E-4626497B97BD}
{0DFDAC71-BCB9-44CF-A44A-E8288E75246F} = {FB7A9794-06D2-42CF-939E-4626497B97BD}
{8F11DADB-557A-4ECF-BEBB-19AFA71998A1} = {FB7A9794-06D2-42CF-939E-4626497B97BD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {80ED12A5-C899-459F-A181-ADCC9D680DE5}
Expand Down
7 changes: 7 additions & 0 deletions aspnet-core/LINGYUN.MicroService.Workflow.sln
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Saas.EntityFram
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.AspNetCore.HttpOverrides", "framework\common\LINGYUN.Abp.AspNetCore.HttpOverrides\LINGYUN.Abp.AspNetCore.HttpOverrides.csproj", "{4D055853-DE80-4145-BB2F-33EB6B379F5E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Security", "framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj", "{E4783690-052A-4AB0-837E-BDBC77CC7EEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -431,6 +433,10 @@ Global
{4D055853-DE80-4145-BB2F-33EB6B379F5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D055853-DE80-4145-BB2F-33EB6B379F5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D055853-DE80-4145-BB2F-33EB6B379F5E}.Release|Any CPU.Build.0 = Release|Any CPU
{E4783690-052A-4AB0-837E-BDBC77CC7EEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4783690-052A-4AB0-837E-BDBC77CC7EEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4783690-052A-4AB0-837E-BDBC77CC7EEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4783690-052A-4AB0-837E-BDBC77CC7EEC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -504,6 +510,7 @@ Global
{911B7C56-1908-42B5-BCE8-860DE650AE31} = {AD002164-CFB4-4583-BF13-62C815009ADE}
{CAE0492C-11A3-424C-8613-7DAB83E4FB60} = {AD002164-CFB4-4583-BF13-62C815009ADE}
{4D055853-DE80-4145-BB2F-33EB6B379F5E} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A}
{E4783690-052A-4AB0-837E-BDBC77CC7EEC} = {6DA78E72-BA55-4ECF-97DB-6258174D3E2A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6BB7A5DE-DA12-44DC-BC9B-0F6CA524346F}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\..\configureawait.props" />
<Import Project="..\..\..\common.props" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Volo.Abp.Security" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="IdentityModel" Version="$(IdentityModelPackageVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using IdentityModel;

namespace Volo.Abp.Security.Claims;

public static class JwtClaimTypesMapping
{
public static void MapAbpClaimTypes()
{
AbpClaimTypes.UserId = JwtClaimTypes.Subject;
AbpClaimTypes.Role = JwtClaimTypes.Role;
AbpClaimTypes.UserName = JwtClaimTypes.PreferredUserName;
AbpClaimTypes.Name = JwtClaimTypes.GivenName;
AbpClaimTypes.SurName = JwtClaimTypes.FamilyName;
AbpClaimTypes.PhoneNumber = JwtClaimTypes.PhoneNumber;
AbpClaimTypes.PhoneNumberVerified = JwtClaimTypes.PhoneNumberVerified;
AbpClaimTypes.Email = JwtClaimTypes.Email;
AbpClaimTypes.EmailVerified = JwtClaimTypes.EmailVerified;
AbpClaimTypes.ClientId = JwtClaimTypes.ClientId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"Default": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456;SslMode=None",
"AbpIdentity": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456;SslMode=None",
"OpenIddict": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456;SslMode=None",
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None"
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ protected async virtual Task SeedAdminRolePermissionsAsync(Guid tenantId)
{
using (CurrentTenant.Change(tenantId))
{


Logger.LogInformation("Seeding the new tenant admin role permissions...");
var definitionPermissions = await PermissionDefinitionManager.GetPermissionsAsync();
var grantPermissions = definitionPermissions
Expand Down
2 changes: 1 addition & 1 deletion aspnet-core/modules/oss-management/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ File-Management更名为Oss-Management
* [LINGYUN.Abp.OssManagement.FileSystem.ImageSharp](./LINGYUN.Abp.OssManagement.FileSystem.ImageSharp) Oss本地对象的ImageSharp扩展,当前端传递需求处理对象时,此模块用于实现基于图形文件流的处理
* [LINGYUN.Abp.OssManagement.FileSystem.Imaging](./LINGYUN.Abp.OssManagement.FileSystem.Imaging) Oss本地对象的Volo.Abp.Imaging扩展
* [LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp](./LINGYUN.Abp.OssManagement.FileSystem.Imaging.ImageSharp) Oss本地对象的Volo.Abp.Imaging.ImageSharp扩展
* [LINGYUN.Abp.OssManagement.Nexus](./LINGYUN.Abp.OssManagement.Nexu s) Oss管理的Nexus实现,管理来自私有Nexus仓库的RAW存储类型
* [LINGYUN.Abp.OssManagement.Nexus](./LINGYUN.Abp.OssManagement.Nexus) Oss管理的Nexus实现,管理来自私有Nexus仓库的RAW存储类型

### 权限定义

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"HostName": "127.0.0.1",
"Port": 5672,
"UserName": "admin",
"Password": "admin",
"Password": "123456",
"ExchangeName": "LINGYUN.Abp.Application",
"VirtualHost": "/"
}
Expand Down
4 changes: 2 additions & 2 deletions aspnet-core/services/LY.MicroService.AuthServer/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": "7.3.2",
"version": "8.1.0",
"name": "my-app-auth-server",
"private": true,
"dependencies": {
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "2.3.3"
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "3.1.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using Autofac.Core;
using DotNetCore.CAP;
using DotNetCore.CAP;
using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.Localization.CultureMap;
using LINGYUN.Abp.Saas;
using LINGYUN.Abp.Serilog.Enrichers.Application;
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
using LINGYUN.Abp.TextTemplating;
using Medallion.Threading.Redis;
using Medallion.Threading;
using Medallion.Threading.Redis;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Caching.StackExchangeRedis;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Logging;
using Microsoft.OpenApi.Models;
using StackExchange.Redis;
using System;
Expand All @@ -36,13 +36,10 @@
using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;
using Microsoft.IdentityModel.Logging;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement;
using Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;

namespace LY.MicroService.BackendAdmin;

Expand All @@ -62,6 +59,7 @@ private void PreConfigureFeature()

private void PreConfigureApp(IConfiguration configuration)
{
JwtClaimTypesMapping.MapAbpClaimTypes();
AbpSerilogEnrichersConsts.ApplicationName = ApplicationName;

PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options =>
Expand Down Expand Up @@ -252,7 +250,7 @@ private void ConfigureIdentity(IConfiguration configuration)
Configure<AbpClaimsPrincipalFactoryOptions>(options =>
{
options.IsDynamicClaimsEnabled = true;
options.RemoteRefreshUrl = configuration["AuthServerUrl"] + options.RemoteRefreshUrl;
options.RemoteRefreshUrl = configuration["App:RefreshClaimsUrl"] + options.RemoteRefreshUrl;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<ProjectReference Include="..\..\framework\logging\LINGYUN.Abp.Serilog.Enrichers.UniqueId\LINGYUN.Abp.Serilog.Enrichers.UniqueId.csproj" />
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Sms.Aliyun\LINGYUN.Abp.Sms.Aliyun.csproj" />
<ProjectReference Include="..\..\framework\mvc\LINGYUN.Abp.AspNetCore.Mvc.Wrapper\LINGYUN.Abp.AspNetCore.Mvc.Wrapper.csproj" />
<ProjectReference Include="..\..\framework\security\LINGYUN.Abp.Security\LINGYUN.Abp.Security.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
]
},
"CorsOrigins": "http://127.0.0.1:3100",
"ShowPii": true
"ShowPii": true,
"RefreshClaimsUrl": "http://127.0.0.1:30015"
},
"AuthServerUrl": "http://127.0.0.1:30015",
"Auditing": {
"AllEntitiesSelector": true
},
Expand Down
Loading

0 comments on commit 94e1bf4

Please sign in to comment.