2017-02-08 8 views
5

私はIdentityServer4デモプロジェクトを試していますが、IProfileServiceの実装ではProfileDataRequestContext.IssuedClaimsにユーザークレームを追加しています。私が気づいたことの1つは、context.RequestedClaimTypesコレクションがあります。これは、私が試したすべてのリソース/アイデンティティ/スコープ構成のバリエーションでは常に空です。このコレクションにはどのような条件の下でデータがありますか?ProfileDataRequestContext.RequestedClaimTypesが空でないのはいつですか?

答えて

-1

client.GetClaimsFromUserInfoEndpoint = trueを設定し、/connect/userinfoエンドポイントに追加往復を行い、リクエストが値 "sub"を要求した場合、それがわかりました。

7

ApiResourcesの定義でUserClaimsを定義すると、これらはcontext.RequestClaimTypesに設定されます。たとえば :

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) } 
} 

次に、あなたProfileDataRequestContext.RequestClaimTypesあなたが合うかあなたのアイデンティティ・サーバーを満たすためにのために、これらの要求の主張が含まれています。

関連する問題