【发布时间】:2011-09-03 23:19:21
【问题描述】:
我正在构建 WIF STS,并且能够生成令牌。如何将令牌返回到原始 URL。我注意到这存在于 wctx 参数中,格式为 ru=。如何在不手动将其解析为字符串的情况下提取它?
【问题讨论】:
我正在构建 WIF STS,并且能够生成令牌。如何将令牌返回到原始 URL。我注意到这存在于 wctx 参数中,格式为 ru=。如何在不手动将其解析为字符串的情况下提取它?
【问题讨论】:
如果你想将令牌返回给依赖方,你可以使用类似这样的ProcessRequest方法:
var claims = new List<Claim>
{
new Claim(WSIdentityConstants.ClaimTypes.Name, User.Identity.Name),
new Claim(ClaimTypes.AuthenticationMethod, FormsAuthenticationHelper.GetAuthenticationMethod(User.Identity))
};
var identity = new ClaimsIdentity(claims, STS.TokenServiceIssueTypes.Native);
var principal = ClaimsPrincipal.CreateFromIdentity(identity);
FederatedPassiveSecurityTokenServiceOperations.ProcessRequest(
Request,
principal,
StarterTokenServiceConfiguration.Current.CreateSecurityTokenService(),
Response);
如果您只是想提取 URL 参数,请查看 WSFederationMessage.CreateFromUri。
【讨论】:
SecurityTokenService 派生类中覆盖GetScope。如果您想更改回复,只需使用以下内容:protected override Scope GetScope( Microsoft.IdentityModel.Claims.IClaimsPrincipal principal, RequestSecurityToken request) { Scope scope = new Scope(request); scope.ReplyToAddress = yourAddress; return scope; }