2017-05-03 7 views
0

Windows 인증과 함께 신원 확인 서버 3을 사용하고 사용자 토큰에 클레임을 추가하고 있습니다. GetProfileDataAsync가 두 번 호출되는 것을 보았습니다. 호출자는 요청 된 클레임이없고 "ClaimsProviderIdentityToken"이 호출자입니다. 역할, 전자 메일, "ClaimsProviderAccessToken"에있는 것과 같은 RequestedClaimTypes를 얻으려면 어떻게해야합니까 ??Identity Server 및 액세스 토큰 클레임

public override Task GetProfileDataAsync(ProfileDataRequestContext context) 
    { 
     // issue the claims for the user 
     var user = Users.SingleOrDefault(x => x.Subject == context.Subject.GetSubjectId()); 
     if (user != null && context.RequestedClaimTypes != null) 
     { 
      context.IssuedClaims = user.Claims.Where(x => context.RequestedClaimTypes.Contains(x.Type)); 
     } 
     //NOTE: Uncomment and all the claims I need are in access token ?? Comment out and no claims in Access Token ?? 
     //context.IssuedClaims = user.Claims; 

     return Task.FromResult(0); 
    } 

다음은 액세스 토큰에 있어야 주장을 요청하는 내 범위의 주장이다 :

new Scope 
       { 
        Name = "api", 
        Enabled = true, 
        DisplayName = "Sample API", 
        Description = "Access to a simple API", 
        Type= ScopeType.Resource, 
        IncludeAllClaimsForUser = true, 


        Claims = new List<ScopeClaim> 
        { 

         new ScopeClaim(Constants.ClaimTypes.Name), 
         new ScopeClaim(Constants.ClaimTypes.Role), 
         new ScopeClaim(Constants.ClaimTypes.Email),       
        }, 


        ScopeSecrets = new List<Secret> 
        { 
         new Secret("api-secret".Sha256()) 
        } 
       } 

나는 뭔가를 놓치고 또는 그냥 user.Claims에 context.IssuedClaims를 설정하는 것이 올바른지 또는 RequestedClaimTypes로 파일을해야합니까 ?? 나는 이것이 실제로 어떻게 작동하는지 알기 위해 조금 노력하고 잃어 버렸고 context.IssuedClaims = user.Claims를 설정하면 확실하지 않다.

답변

0

실제로 액세스 권한 토큰을 요청할 때 context.RequestedClaimsTypes가 null이 아니라는 것을 제거하면 IncludeAllClaimsForUser = true가 클레임을 지우는 응답을 찾았습니다.