我通过覆盖SecurityTokenService并使用WCF托管它来创建STS。我也创建了一个依赖方和测试客户端。客户端成功重定向到STS(如果我在GetOutputIdentity方法中放置断点,程序将停止)。现在我需要拒绝我的RP中除一个角色以外的所有用户的访问权限。我该怎么做?她是我的配置:
protected override ClaimsIdentity GetOutputClaimsIdentity(ClaimsPrincipal principal,
RequestSecurityToken request,
Scope scope)
{
string authenticationType = principal.Identity.AuthenticationType;
var outputIdentity = new ClaimsIdentity(authenticationType);
outputIdentity.AddClaim(new Claim(ClaimTypes.Role, role));
outputIdentity.AddClaim(new Claim(ClaimTypes.Name, userName));
return outputIdentity;
}
依赖方配置:
<customBinding>
<binding name="secureBinding">
<security authenticationMode="IssuedToken" requireDerivedKeys="false" >
<issuedTokenParameters>
<issuer address="http://localhost:1318/Services/SecurityTokenService.svc">
</issuer>
<issuerMetadata address="http://localhost:1318/Services/SecurityTokenService.svc/mex"></issuerMetadata>
</issuedTokenParameters>
</security>
<httpTransport></httpTransport>
</binding>
</customBinding>