Search code examples
c#securityspring-securitywebmethod

C# - Looking for WebService Security like Spring Security


Is there any way to secure Web Methods in c# like Spring Security Annotations?

something like:

public interface MyWebService {

    @Secured("ROLE_USER")
    public void delete(int cid);

}

Thanks


Solution

  • Yes. Take a look at authorization for WCF. Specifically, the .Net analog for controlling security is with the PrincipalPermissionAttribute. For this to work, you will need to make sure your current context is associated with an identity, for instance, by requiring a username/password combination before connecting to your service and using those credentials to set the user account for the session.