1
votes

I have a problem using JWT tokens as validation. The problem is that the flow calls the function JwtSecurityTokenHandler.ReadOnlyCollection ValidateToken(SecurityToken token). Which is obsolete and it tells me to use the function JwtSecurityTokenHandler.ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken). But how do i do this?

My web.config is configured in this way.

<system.identityModel>
<identityConfiguration saveBootstrapContext="true">
  <audienceUris>
    <add value="urn:xyz" />
  </audienceUris>
  <securityTokenHandlers>
    <add type="System.IdentityModel.Tokens.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt, Version=4.0.0.0" />
    <securityTokenHandlerConfiguration>
      <certificateValidation certificateValidationMode="PeerTrust" />
    </securityTokenHandlerConfiguration>
  </securityTokenHandlers>
  <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <trustedIssuers>
                <add name="XXX" thumbprint="[NNN]" />
            </trustedIssuers>
        </issuerNameRegistry>
  <issuerTokenResolver type="System.IdentityModel.Tokens.NamedKeyIssuerTokenResolver, System.IdentityModel.Tokens.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</identityConfiguration>
</system.identityModel>
  <system.identityModel.services>
   <federationConfiguration>
     <wsFederation passiveRedirectEnabled="true" issuer="https://xxx/issue/wsfed" realm="urn:xyz" requireHttps="true" />
        </federationConfiguration>
       </system.identityModel.services>
1

1 Answers

1
votes

For all you people out there that have the same issue. I found a solution to this problem. It's an intermediate solution and would still appreciate if someone could solve this anyway.

The problem is that System.IdentityModel.Tokens.Jwt, Version=4.0.0.0 has made it's Validate(SecurityToken) function on it's JwtSecurityTokenHandler obsolete.

  • If you only want to enable JWT-tokes with configuration, then use Version 3.0.2 of the nuget.
  • If you rather stick with the latest version, you could reflect the logic contained in the Validate function from the previous version and put it in an inherited class from the JwtSecurityTokenHandler and register that in the config.

As i mentioned before, i would still like to get this item resolved in a better way then both approaches i described above.