1
votes

I have implemented a custom STS and it works good with Saml token. Now I need to obtain the token in JWT format, because I need to pass it later to WCF Rest based service. I've installed the Jwt Token Handler from: https://nuget.org/packages/System.IdentityModel.Tokens.Jwt/

This is a part of the Web.config in the Sts project:

  <securityTokenHandlers name="ActAs">
    <clear/>
    <add type="System.IdentityModel.Tokens.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt"/>
    <!--<add type="System.IdentityModel.Tokens.SamlSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
    <add type="System.IdentityModel.Tokens.Saml2SecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />-->

    <securityTokenHandlerConfiguration>
      <audienceUris>
        <add value="URL_RP_STS"/>
        <add value="URL_CLIENT"/>
      </audienceUris>
      <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
        <trustedIssuers>
          <add thumbprint="..." name="StsCustom" />
        </trustedIssuers>
      </issuerNameRegistry>
    </securityTokenHandlerConfiguration>
  </securityTokenHandlers>

  <audienceUris>
    <add value="URL_RP_STS" />
  </audienceUris>
  <!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.-->
  <certificateValidation certificateValidationMode="None" />
  <issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
    <authority name="StsCustom">
      <keys>
        <add thumbprint="..." />
      </keys>
      <validIssuers>
        <add name="StsCustom" />
      </validIssuers>
    </authority>
  </issuerNameRegistry>
</identityConfiguration>    

But the Sts continue to generate a SamlSecurityToken. Is necessary some other configuration to set a specific token type? Is not suffice adding the Jwt token handler in the securityTokenHandlers section? Thanks

1

1 Answers

0
votes

How do you request the token? In WS-Trust you can pass in the token type in the RST. For WS-Federation you need to write code in the STS for that.