- ABP Framework version: v5.2.2
- UI Type: Angular
- Database System: EF Core (SQL Server)
- Auth Server Separated (for Angular): yes
Hi, we are using Identity Server 4 and have a custom claim called 'institution_id,' which we have included in the access token by adding it to the ApiResourcesClaims.
However, this claim does not appear in the id_token, and we need it to be included. Any customization needed to achieve this?
Your help would be greatly appreciated.
6 Answer(s)
-
0
hi
Please share your identity server config. eg
Client
,API Scope
,Identity Resource
Thanks.
-
0
-
0
hi
Please share the code of seeding the identity server's configuration.
-
0
Hi @maliming,
I have shared you the source code via email.
-
0
hi
You can add a new
Identity Resouce
namedinstitution_id
.Add the
institution_id
to the request's scopes.options.Scope.Add("institution_id");
[UnitOfWork] public virtual async Task SeedAsync(DataSeedContext context) { using (_currentTenant.Change(context?.TenantId)) { await _identityResourceDataSeeder.CreateStandardResourcesAsync(); if (!await _identityResourceRepository.CheckNameExistAsync(SHDPClaimTypes.InstitutionId)) { var institutionIdIdentityResource = new IdentityResource(_guidGenerator.Create(), SHDPClaimTypes.InstitutionId); institutionIdIdentityResource.AddUserClaim(SHDPClaimTypes.InstitutionId); await _identityResourceRepository.InsertAsync(institutionIdIdentityResource); if (await _claimTypeRepository.AnyAsync(SHDPClaimTypes.InstitutionId)) { await _claimTypeRepository.InsertAsync( new IdentityClaimType( _guidGenerator.Create(), SHDPClaimTypes.InstitutionId, isStatic: true ) ); } } await CreateClaimTypesAsync(); await CreateApiResourcesAsync(); await CreateClientsAsync(); } }
var commonScopes = new[] { "email", "openid", "profile", "role", "phone", "address", "DigitalPlatform", "institution_id" };
-
0
Hi @maliming, following your steps, I managed to add the custom claim into id token.
Thanks a lot for your help.