1

我尝试在 KentorIT-authservices SampleOwinApplication 中获取原始 SAML 资产 (XML)。

我尝试了这些解决方案:

解决方案 1

在启动 ConfigureAuth 添加:

 FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SaveBootstrapContext = true;

访问令牌:

    var icp = System.Security.Claims.ClaimsPrincipal.Current;

    var claimsIdentity = icp.Identity as System.Security.Claims.ClaimsIdentity;

    var ctx = claimsIdentity.BootstrapContext as System.IdentityModel.Tokens.BootstrapContext;

    var token = ctx.SecurityToken;

但 BootstrapContext 为空。

解决方案 2

我设置了 SpOptions:

spOptions.SystemIdentityModelIdentityConfiguration.SaveBootstrapContext = true;

Saml2PSecurityTokenHandler当我在方法中的类中调试时CreateClaims设置了identity.BootstrapContext。还行吧。

但是当我尝试访问令牌时,例如从 HomeController BootstrapContext 为空。

    var claimsIdentity = icp.Identity as System.Security.Claims.ClaimsIdentity;

    var ctx = claimsIdentity.BootstrapContext as System.IdentityModel.Tokens.BootstrapContext;

    var token = ctx.SecurityToken;

感谢

4

0 回答 0