2017-12-07 1 views
0

현재 API를 개발 중입니다. 토큰은 IdentityServer4에서 반환됩니다.잘못된 소유권 주장 유형

토큰 소유권 주장에서 현재 승인 된 사용자의 ID 인 하위 ID를 되 찾으려합니다. 나는 여기의 주장에서 그것을 볼 수있다. 하위 또는 피사체가

"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"

enter image description here

로 전환하는 이유

{ 
    "nbf": 1512632838, 
    "exp": 1512636438, 
    "iss": "http://localhost:5000", 
    "aud": [ 
    "http://localhost:5000/resources", 
    "testapi" 
    ], 
    "client_id": "ServiceAccountAccess", 
    "sub": "21248582", 
    "auth_time": 1512632823, 
    "idp": "local", 
    "name": "TestUser", 
    "resource_id": "21260601", 
    "xena_fiscal_id": "21875", 
    "fiscal_name": "My company", 
    "picture_url": "/Content/images/avatar-company-xena.jpg", 
    "application_id": "16140911", 
    "scope": [ 
    "openid", 
    "profile", 
    "testapi" 
    ], 
    "amr": [ 
    "password" 
    ] 
} 

내 API 호출은 매우 간단합니다

[Authorize] 
    public async Task<ActionResult> ChangeFiscal([FromBody] long fiscalId) 
    { 

     var name = User.Claims.Where(c => c.Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier") 
      .Select(c => c.Value).SingleOrDefault(); 

    } 

내가 뭘 이해하지 못할 것은

나는 그것 마이크로 소프트 JWT 핸들러는 마이크로 소프트 고유의 것들에 이러한 표준 주장을 켜지는지 알아 내기 위해 시간을 가지고 주장

{ 
    "nbf": 1512653706, 
    "exp": 1512657306, 
    "iss": "http://localhost:5000", 
    "aud": [ 
    "http://localhost:5000/resources", 
    "testapi" 
    ], 
    "client_id": "ServiceAccountAccess", 
    "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "21248582", 
    "auth_time": 1512652100, 
    "http://schemas.microsoft.com/identity/claims/identityprovider": "local", 
    "name": "TestUser", 
    "supporter": "21248582", 
    "http://schemas.microsoft.com/claims/authnmethodsreferences": "password", 
    "resource_id": "21527443", 
    "xena_fiscal_id": "21876", 
    "fiscal_name": "this", 
    "picture_url": "/Content/images/avatar-company-xena.jpg", 
    "scope": [ 
    "openid", 
    "profile", 
    "testapi" 
    ] 
} 

답변

0

그것의 적지로 수행 된 API에서 볼 수 있습니다. 내가이 짜증나는 "기능"을 끌 수 있었다 시작 구성 방법에 다음 줄을 추가하여

JwtSecurityTokenHandler.InboundClaimTypeMap.Clear() 
+1

이 마이크로 소프트를 감사하는 것을 잊지 마십시오. – leastprivilege

+0

나는 어제 크게 큰소리로 그랬다. – DaImTo