2017-03-08 6 views
2

観客にオフセット:.NETのコアクライアントはIdentityServer v3ので認証しない - 考える

IdentityServer v3の JavaScriptクライアント AspのコアAPIクライアント

はJavaScriptクライアントはidentityserverで認証し、AになりAPIへのベアラトークンによるリクエスト

apiはリソース所有者のワークフローを使用するように構成されています

問題: は今、私が手:

オーディエンス: 'http://localhost/identity/resources' を。一致していませんでした: validationParameters.ValidAudience: 'MyApi' または validationParameters.ValidAudiences: 'NULL'

Obiviously Audianceが一致していませんが。 私は何が欠けていますか?

コンフィグ

アイデンティティサーバーでApiClient:アイデンティティサーバーに接続するためのAPIで

return new Client 
      { 
       Enabled = true, 
       ClientId = "MyApi", 
       ClientName = "The client for the Groupl Api", 
       ClientSecrets = new List<Secret> 
       { 
        new Secret("foo".Sha256()) 
       }, 
       Flow = Flows.ResourceOwner, 
       AllowedScopes = ClientConstants.AllowedGrouplScopes() 
      }; 

:ここ

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); 


     var authority = config["identity:authority:url"]; 
     app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions 
     { 
      Authority = authority, 
      RequireHttpsMetadata = false, 
      EnableCaching = false, 

      ApiName = "myApi", //Correct that this is the client id? 
      ApiSecret = "foo" 
     }); 

要求(access_tokenは省略)

GET /api/values HTTP/1.1 
Host: localhost:59364 
Content-Type: application/json 
Authorization: Bearer {access_token} 

更新

私はLegacyAudienceValidation = trueを設定すると、すべてが正常に動作しますが、私はこれを正しく処理するかどうかはわかりませんか?

答えて

2

理由は、認証の動作が変更されたことです。 IdentityServer 3は複数の視聴者をサポートしていませんでした。アイデンティティサーバー4はそうです。したがって、古い取り扱いの場合は、true

に設定する必要があります
関連する問題