2017-12-07 9 views
0

現在、私はAPIを開発中です。トークンはIdentityServer4から戻されます。不正な申し立てタイプ

トークンクレームから現在承認されたユーザーのIDであるサブIDを取得しようとしています。私はここの主張でそれを見ることができます。

{ 
    "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コールは、サブや被写体が

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

enter image description here

になっている理由を私は理解して傾ける何

[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ハンドラーは、Microsoft独自のものにこれらの標準的な主張を回すことを把握するために時間を取ら請求

{ 
    "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から見ることができます。私はそのために、Microsoftに感謝することを忘れないでください、この迷惑な「機能」

JwtSecurityTokenHandler.InboundClaimTypeMap.Clear() 
+1

をオフにすることができたスタートアップの設定方法に以下の行を追加することで

。 – leastprivilege

+0

私は昨日非常に大声で、少なくとも働いていました – DaImTo

関連する問題