我已经实现了一个自定义 STS,它适用于 Saml 令牌。现在我需要获取 JWT 格式的令牌,因为我需要稍后将它传递给基于 WCF Rest 的服务。我已经从以下位置安装了 Jwt 令牌处理程序: https ://nuget.org/packages/System.IdentityModel.Tokens.Jwt/
这是 Sts 项目中 Web.config 的一部分:
<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>
但是 Sts 继续生成一个 SamlSecurityToken。是否需要一些其他配置来设置特定的令牌类型?在 securityTokenHandlers 部分添加 Jwt 令牌处理程序还不够吗?谢谢