IdentityServer / IdentityServer3.AccessTokenValidation

OWIN Middleware to validate access tokens from IdentityServer3
Apache License 2.0
90 stars 149 forks source link

Version conflict on JwtSecurityTokenHandler #21

Closed Ph47 closed 9 years ago

Ph47 commented 9 years ago

Error CS0433: The type 'JwtSecurityTokenHandler' exists in both 'System.IdentityModel.Tokens.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and 'System.IdentityModel.Tokens, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null'.

Steps:

  1. Add to dependencies in project.json: "Thinktecture.IdentityServer.v3.AccessTokenValidation": "1.0.0-rc"
  2. Add to Startup.cs to void Configure: JwtSecurityTokenHandler.InboundClaimTypeMap = ClaimMappings.None;
  3. Run kpm build.

Dependency conflict:

Thinktecture.IdentityServer.v3.AccessTokenValidation (1.0.0-rc) > Microsoft.Owin.Security.Jwt (3.0.0) > System.IdentityModel.Tokens.Jwt (4.0.0)

And

Thinktecture.IdentityServer.v3.AccessTokenValidation (1.0.0-rc) > Microsoft.IdentityModel.Protocol.Extensions (2.0.0-beta1-01112054-1) > System.IdentityModel.Tokens (5.0.0-beta1-01112054-1)

Ph47 commented 9 years ago

My temporary workaround:

        string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
        Assembly.LoadFile(home + @"\.kpm\packages\System.IdentityModel.Tokens.Jwt\4.0.0\lib\net45\System.IdentityModel.Tokens.Jwt.dll")
            .GetType("System.IdentityModel.Tokens.JwtSecurityTokenHandler")
            .GetProperty("InboundClaimTypeMap")
            .SetValue(null, ClaimMappings.None);
        Assembly.LoadFile(home + @"\.kpm\packages\System.IdentityModel.Tokens\5.0.0-beta1-01112054-1\lib\aspnet50\System.IdentityModel.Tokens.dll ")
            .GetType("System.IdentityModel.Tokens.JwtSecurityTokenHandler")
            .GetProperty("InboundClaimTypeMap")
            .SetValue(null, ClaimMappings.None);