2009-04-22 94 views
2

我試圖實施以下情形:wsFederationHttpBinding,將自定義用戶身份STS

  1. 客戶通過它cridentials到STS。
  2. STS應用自定義AuthorizationPolicy來確定可供特定用戶使用的一組聲明,併發出安全令牌。
  3. 客戶端將令牌傳遞給業務服務,該業務服務根據他們從令牌獲得的一組索賠確定用戶的特權。

看起來像第一步是主要問題。由於 MSDN建議wsFederationHttpBinding的消息元素沒有clientCredentialsType。因此,只要我的AuthorizationPolicy檢查evaluateContext.Properties [「Identities」],它就會看到它的WindowsIdentity。我想通過自定義存儲(DB)來驗證用戶身份。

有什麼辦法可以用wsFederationHttpBinding來完成它嗎?

回答

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"); 
    } 
} 
相關問題