diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs index a032ce6824..80c275252c 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsService.cs @@ -4,12 +4,15 @@ using System.Security.Claims; using IdentityModel; using IdentityServer4.Services; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Volo.Abp.Security.Claims; namespace Volo.Abp.IdentityServer { public class AbpClaimsService : DefaultClaimsService { + protected readonly AbpClaimsServiceOptions Options; + private static readonly string[] AdditionalOptionalClaimNames = { AbpClaimTypes.TenantId, @@ -20,20 +23,21 @@ namespace Volo.Abp.IdentityServer JwtClaimTypes.FamilyName, }; - public AbpClaimsService(IProfileService profile, ILogger logger) + public AbpClaimsService( + IProfileService profile, + ILogger logger, + IOptions options) : base(profile, logger) { + Options = options.Value; } protected override IEnumerable FilterRequestedClaimTypes(IEnumerable claimTypes) { return base.FilterRequestedClaimTypes(claimTypes) - .Union(new []{ - AbpClaimTypes.TenantId, - AbpClaimTypes.EditionId - }); + .Union(Options.RequestedClaims); } - + protected override IEnumerable GetOptionalClaims(ClaimsPrincipal subject) { return base.GetOptionalClaims(subject) @@ -52,4 +56,4 @@ namespace Volo.Abp.IdentityServer } } } -} \ No newline at end of file +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsServiceOptions.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsServiceOptions.cs new file mode 100644 index 0000000000..a940cb6119 --- /dev/null +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpClaimsServiceOptions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace Volo.Abp.IdentityServer +{ + public class AbpClaimsServiceOptions + { + public List RequestedClaims { get; } + + public AbpClaimsServiceOptions() + { + RequestedClaims = new List(); + } + } +} diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs index 328c70cc8a..55121aec99 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AbpIdentityServerDomainModule.cs @@ -10,7 +10,6 @@ using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.Identity; using Volo.Abp.IdentityServer.ApiResources; using Volo.Abp.IdentityServer.AspNetIdentity; -using Volo.Abp.IdentityServer.ApiScopes; using Volo.Abp.IdentityServer.Clients; using Volo.Abp.IdentityServer.Devices; using Volo.Abp.IdentityServer.IdentityResources; @@ -19,6 +18,7 @@ using Volo.Abp.Modularity; using Volo.Abp.ObjectExtending; using Volo.Abp.ObjectExtending.Modularity; using Volo.Abp.Security; +using Volo.Abp.Security.Claims; using Volo.Abp.Validation; using Volo.Abp.Threading; @@ -54,6 +54,14 @@ namespace Volo.Abp.IdentityServer options.EtoMappings.Add(typeof(AbpIdentityServerDomainModule)); }); + Configure(options => + { + options.RequestedClaims.AddRange(new []{ + AbpClaimTypes.TenantId, + AbpClaimTypes.EditionId + }); + }); + AddIdentityServer(context.Services); } diff --git a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpProfileService.cs b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpProfileService.cs index 3eb14131f1..224abc6c10 100644 --- a/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpProfileService.cs +++ b/modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpProfileService.cs @@ -24,7 +24,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity } [UnitOfWork] - public async override Task GetProfileDataAsync(ProfileDataRequestContext context) + public override async Task GetProfileDataAsync(ProfileDataRequestContext context) { using (CurrentTenant.Change(context.Subject.FindTenantId())) { @@ -33,7 +33,7 @@ namespace Volo.Abp.IdentityServer.AspNetIdentity } [UnitOfWork] - public async override Task IsActiveAsync(IsActiveContext context) + public override async Task IsActiveAsync(IsActiveContext context) { using (CurrentTenant.Change(context.Subject.FindTenantId())) {