I have a UserAccountService with different methods, some of which require the user to be authenticated (e.g. ChangePassword, ChangeUserData) and some not (RegisterUser).
However it seems I can't seem to get it to work, so that only some methods require authentication.
The methods that require authentication are decorated with
[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
In my app.config I have a binding specified which uses encryption and requests UserName credentials:
<binding name="authenticatedBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
(I am using basicHttpBinding)
I also have a custom authentication provider configured:
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="..." />
</serviceCredentials>
With this configuration I can't seem to call any methods on the service without being authenticated.
If I leave out the security configuration, then I can call the methods that don't require authentication, but the message credentials are no longer being transported.
How do I have to configure my service, so that it allows all methods to be called and only requires the username/password to be set when the PrincipalPermission demands it?
I am using Silverlight as my client, if that's important...
Thanks!
Security settings can be fine grained at end-point level but not within a contract - so you cannot combine secure & unsecure methods in a way that you desired. I will suggest that
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With