2016-10-26 5 views
0

WIF 4.5を使用しているWebAPIアプリケーションでJWT(Json Web Token)をサポートしたいと思っていました。WIF 4.5でJWTSecurityTokenHandlerをサポートする方法はありますか?

私は、JWTSecurityTokenHandlerという古いバージョンのWIFと統合されているようなSystem.IdentityModel.Tokens.Jwt 5.0.0ナゲットパッケージを使用しています。

問題は、ハンドラがを派生し、System.IdentityModel.Tokens.SecurityTokenHandlerからではなく、configセクションが期待していることです。

<system.identityModel> 
     <identityConfiguration> 
      <audienceUris> 
       <add value="http://localhost:49482/" /> 
      </audienceUris> 
      <securityTokenHandlers> 
       <add type="System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt" /> 
       <securityTokenHandlerConfiguration> 
        <certificateValidation certificateValidationMode="PeerTrust" /> 
       </securityTokenHandlerConfiguration> 
      </securityTokenHandlers> 
     </identityConfiguration> 
</system.identityModel> 

がどのように私はWIF 4.5にJWTをサポートすることができます。

Parser Error Message: ID1029: The custom type is not suitable because it does not extend the correct base class. 
CustomType: 'System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 
BaseClass: 'System.IdentityModel.Tokens.SecurityTokenHandler' 

私の設定は次のようになります。

私はそのため理解できる例外を取得しますか?そのためにこのパッケージを使用する方法はありますか?私は何か間違っているのですか?

答えて

1

このパッケージはSystem.IdentityModel APIを含まない.NET標準1.4に対して書かれているため、パッケージにはWIFとの統合はありません。

https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/94に基づいて、System.IdentityModelをWIF構成で使用する場合は、パッケージのバージョン3.xに戻る必要があります。

あなたはいつも自分の書くことができますSystem.IdentityModel.Tokens.SecurityTokenHandlerラップする実装Microsoft.IdentityModel.Tokens.SecurityTokenHandle

関連する問題