【问题标题】:WCF deny anyone without specific role using custom STSWCF 使用自定义 STS 拒绝没有特定角色的任何人
【发布时间】:2015-04-29 16:24:07
【问题描述】:

我通过重写 SecurityTokenService 制作了一个 STS,并使用 WCF 托管它。我还创建了一个依赖方和测试客户端。客户端成功重定向到 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>

【问题讨论】:

    标签: wcf wif role sts-securitytokenservice


    【解决方案1】:

    您可以使用自定义AuthorizationManager 来验证RP 的每个调用。此类提供 CheckAccess 方法,根据传入的声明实现您的自定义验证。

    【讨论】:

      猜你喜欢
      • 2011-02-10
      • 2021-05-25
      • 1970-01-01
      • 1970-01-01
      • 2019-06-29
      • 2014-01-16
      • 1970-01-01
      • 2018-10-03
      • 1970-01-01
      相关资源
      最近更新 更多