From 775cb73b5aad5c93e3fc295fe624c09f407b9549 Mon Sep 17 00:00:00 2001 From: colin Date: Sat, 17 May 2025 13:15:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(openiddict):=20=E7=A7=BB=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=A4=B4=E5=83=8F=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbpOpenIddictAspNetCoreModule.cs | 9 +---- ...SessionOpenIddictClaimsPrincipalHandler.cs | 12 ------- .../AvatarUrlClaimsPrincipalContributor.cs | 33 ------------------- .../Controllers/UserInfoController.cs | 7 ---- 4 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpSessionOpenIddictClaimsPrincipalHandler.cs delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AvatarUrlClaimsPrincipalContributor.cs diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpOpenIddictAspNetCoreModule.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpOpenIddictAspNetCoreModule.cs index 4ecb11e58..c99cdc77c 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpOpenIddictAspNetCoreModule.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpOpenIddictAspNetCoreModule.cs @@ -1,5 +1,4 @@ using LINGYUN.Abp.Identity; -using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; using VoloAbpOpenIddictAspNetCoreModule = Volo.Abp.OpenIddict.AbpOpenIddictAspNetCoreModule; @@ -8,13 +7,7 @@ namespace LINGYUN.Abp.OpenIddict.AspNetCore; [DependsOn( typeof(AbpIdentityDomainSharedModule), typeof(VoloAbpOpenIddictAspNetCoreModule))] +[System.Obsolete("The module has been deprecated and will be removed in future versions")] public class AbpOpenIddictAspNetCoreModule : AbpModule { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(builder => - { - builder.RegisterClaims(new[] { IdentityConsts.ClaimType.Avatar.Name } ); - }); - } } diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpSessionOpenIddictClaimsPrincipalHandler.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpSessionOpenIddictClaimsPrincipalHandler.cs deleted file mode 100644 index 065fa5c43..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AbpSessionOpenIddictClaimsPrincipalHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.OpenIddict; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore; -public class AbpSessionOpenIddictClaimsPrincipalHandler : IAbpOpenIddictClaimsPrincipalHandler, ITransientDependency -{ - public Task HandleAsync(AbpOpenIddictClaimsPrincipalHandlerContext context) - { - return Task.CompletedTask; - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AvatarUrlClaimsPrincipalContributor.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AvatarUrlClaimsPrincipalContributor.cs deleted file mode 100644 index 2177f8717..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/AvatarUrlClaimsPrincipalContributor.cs +++ /dev/null @@ -1,33 +0,0 @@ -using LINGYUN.Abp.Identity; -using Microsoft.Extensions.DependencyInjection; -using System.Linq; -using System.Security.Claims; -using System.Security.Principal; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Identity; -using Volo.Abp.Security.Claims; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore; -public class AvatarUrlClaimsPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency -{ - public async virtual Task ContributeAsync(AbpClaimsPrincipalContributorContext context) - { - var identity = context.ClaimsPrincipal.Identities.FirstOrDefault(); - if (identity != null) - { - if (identity.HasClaim(x => x.Type == IdentityConsts.ClaimType.Avatar.Name)) - { - return; - } - var userManager = context.ServiceProvider.GetRequiredService(); - var user = await userManager.GetUserAsync(context.ClaimsPrincipal); - var userClaims = await userManager.GetClaimsAsync(user); - var userAvatarUrl = userClaims.FirstOrDefault(x => x.Type == IdentityConsts.ClaimType.Avatar.Name); - if (userAvatarUrl != null) - { - identity.AddIfNotContains(new Claim(IdentityConsts.ClaimType.Avatar.Name, userAvatarUrl.Value)); - } - } - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/Controllers/UserInfoController.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/Controllers/UserInfoController.cs index 4bcd71716..71ac6a1ba 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/Controllers/UserInfoController.cs +++ b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore/LINGYUN/Abp/OpenIddict/AspNetCore/Controllers/UserInfoController.cs @@ -1,7 +1,6 @@ using OpenIddict.Abstractions; using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; @@ -36,12 +35,6 @@ public class UserInfoController : VoloUserInfoController claims[OpenIddictConstants.Claims.PreferredUsername] = user.UserName; claims[OpenIddictConstants.Claims.FamilyName] = user.Surname; claims[OpenIddictConstants.Claims.GivenName] = user.Name; - // 重写添加用户头像 - var picture = user.Claims.FirstOrDefault(x => x.ClaimType == AbpClaimTypes.Picture); - if (picture != null) - { - claims[OpenIddictConstants.Claims.Picture] = picture.ClaimValue; - } } if (User.HasScope(OpenIddictConstants.Scopes.Email))