Does WCF have an equivalent of MVC's [Authorize] attribute?

后端 未结 3 1013
感情败类
感情败类 2020-12-17 17:48

I want to decorate certain Operation Contracts with an attribute to authorize the caller by custom logic, something like this:

[ServiceBehavior]
public class         


        
相关标签:
3条回答
  • 2020-12-17 18:18

    Not out of the box - but WCF top-guru Juval Löwy had a very interesting article in MSDN Magazine about Declarative WCF Security which goes in the same direction.

    Juval identified several key security scenarios, and wrapped each of them up into a WCF service behavior to be applied as an attribute on your service class on the server side. Quite an interesting read indeed !

    0 讨论(0)
  • 2020-12-17 18:30

    In my WCF application, I've largely overrided all the default authentication and authorization stuff, and I use some custom processing of the PrincipalPermissionAttribute to check my custom security permissions.

    I have some code snippits of how I did this in this post: .NET Declarative Security: Why is SecurityAction.Deny impossible to work with?

    0 讨论(0)
  • 2020-12-17 18:35

    WCF doesn't have any special attribute for this purpose but you can use PrincipalPermissionAttribute - common approach for declarative role-based security in .NET.

    0 讨论(0)
提交回复
热议问题