I'm trying to implement following scenario:
Looks like the first step is the main problem. As MSDN suggests message element of wsFederationHttpBinding doesn't have clientCredentialsType. As a result, whenever my AuthorizationPolicy examines evaluationContext.Properties["Identities"] it sees WindowsIdentity in it. I'd like to authenticate user against custom storage (DB).
Is there any way to accomplish it with wsFederationHttpBinding?
Well, here's the answer
STS config:
<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>
Username validator
public class UserNameValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (!VerifyCredentials(userName, password))
throw new SecurityException("Invalid credentials");
}
}