【问题标题】:wsFederationHttpBinding, passing custom user Identity to STSwsFederationHttpBinding,将自定义用户身份传递给 STS
【发布时间】:2009-04-22 15:35:48
【问题描述】:

我正在尝试实现以下场景:

  1. 客户端将其凭据传递给 STS。
  2. STS 应用自定义 AuthorizationPolicy 来确定可供特定用户使用的声明集并颁发安全令牌。
  3. 客户端将令牌传递给业务服务,业务服务根据用户从令牌获得的声明集确定用户的权限。

看起来第一步是主要问题。正如 MSDN 建议的那样,wsFederationHttpBinding 的消息元素没有clientCredentialsType。因此,每当我的 AuthorizationPolicy 检查 evaluationContext.Properties["Identities"] 时,它都会在其中看到 WindowsIdentity。我想针对自定义存储 (DB) 对用户进行身份验证。

有没有什么方法可以通过 wsFederationHttpBinding 来完成?

【问题讨论】:

    标签: .net wcf wcf-security


    【解决方案1】:

    好吧,这就是答案

    STS 配置:

    <behaviors>
         <serviceBehaviors>
             <behavior name="STSBehaviour">
                 <!--Custom credentials processing-->
                 <serviceCredentials>
                     <userNameAuthentication userNamePasswordValidationMode="Custom" 
                                             customUserNamePasswordValidatorType="SecurityTokenService.UserNameValidator, SecurityTokenService"/>
                 </serviceCredentials>
                 <!--------------------------------->
             </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <wsHttpBinding>
            <binding name="wsHttpUsername">
                ...
                <security mode="Message">
                    <message clientCredentialType="UserName"
                             negotiateServiceCredential="false"
                             establishSecurityContext="false" />
                </security>
                ...
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service behaviorConfiguration ="STSBehaviour"
                   name="Microsoft.ServiceModel.Samples.SecurityTokenService" >
               ....
        </service>
    </services>
    

    用户名验证器

    public class UserNameValidator : UserNamePasswordValidator
    {
        public override void Validate(string userName, string password)
        {
            if (!VerifyCredentials(userName, password))
                throw new SecurityException("Invalid credentials");
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 2020-02-10
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多