Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is ProfileDataRequestContext.RequestedClaimTypes not empty?

I'm trying out IdentityServer4 demo project and I'm adding user claims to ProfileDataRequestContext.IssuedClaims in IProfileService implementation. One thing I've noticed is that there is a context.RequestedClaimTypes collection, which is always empty in any resource/identity/scope configuration variations I've tried. Under what condition does this collection has data?

like image 557
dstr Avatar asked Feb 08 '17 08:02

dstr


1 Answers

If in the definition of your ApiResources you define UserClaims, these will then be populated in the context.RequestClaimTypes. For example:

new ApiResource
{
  Name = "TestAPI",
  ApiSecrets = { new Secret("secret".Sha256()) },
  UserClaims = {
    JwtClaimTypes.Email,
    JwtClaimTypes.EmailVerified,
    JwtClaimTypes.PhoneNumber,
    JwtClaimTypes.PhoneNumberVerified,
    JwtClaimTypes.GivenName,
    JwtClaimTypes.FamilyName,
    JwtClaimTypes.PreferredUserName
                    },
  Description = "Test API",
  DisplayName = "Test API",
  Enabled = true,
  Scopes = { new Scope("testApiScore) }
}

Then your ProfileDataRequestContext.RequestClaimTypes will contain these request claims, for your Identity Server to fulfil how you see fit.

like image 176
Mashton Avatar answered Jan 03 '23 17:01

Mashton