Open CxistHans opened 3 years ago
After comparing the jwt token of the correct and incorrect requests, it is found that the claim: role and user are missing
You can check the default profile service here: https://github.com/IdentityServer/IdentityServer4/blob/main/src/AspNetIdentity/src/ProfileService.cs
After I added ProfileService, My own API is protected, but Admin Site is not working anymore.
Can you add ProfileService to your project, so we can continue to add our own claims.
`
public class ProfileService
_logger = logger;
_dbContext = dbContext;
}
public async Task GetProfileDataAsync(ProfileDataRequestContext context)
{
IdentityUser mUser = (await _userManager.GetUserAsync(context.Subject)) as IdentityUser;
TicketHolderSecurity security=_dbContext.TicketHolderSecurities.Where(x => x.UserId == mUser.UserName).FirstOrDefault();
if(security!=null)
{
context.IssuedClaims.Add(new Claim("IsTicketHolder", "true"));
context.IssuedClaims.Add(new Claim("TicketHolderId", security.TicketHolderId.ToString()));
context.IssuedClaims.Add(new Claim("PhoneNumber", mUser.PhoneNumber));
}
context.AddRequestedClaims(context.Subject.Claims);
await Task.CompletedTask;
}
public async Task IsActiveAsync(IsActiveContext context)
{
context.IsActive = context.IsActive;
await Task.CompletedTask;
}
}
`
It is working after I restarted Azure Website. This issue can be closed now.
Describe the bug
Completely code initialization data, admin login,Try to enter IdentityServer Admin from IdentityServer
To Reproduce
Added custom IProfileService, then StartupHelpers:.AddProfileService(), then start the project, Try to enter IdentityServer Admin from IdentityServer
version: Templates::2.0.1
ProfileService:
Relevant parts of the log file