Permission names as public constants request

Topics: Core, Customizing Orchard, General
Oct 12, 2013 at 6:07 AM
Edited Oct 12, 2013 at 6:09 AM
Is it possible to make the built-in Orchard permission names as public constants?
I use declarative security with an custom AuthorizeAttribute for my controllers, but I can not use the permission objects and must use strings in the attributes. I prefer to use the constants of the modules self.
[OrchardAuthorization(PermissionName = "EditContent")]
[OrchardAuthorization(PermissionName = Orchard.Core.Contents.EditContent)]
Mar 5, 2014 at 9:55 PM
Can't you simply use Orchard.Core.Contents.EditContent.Name ? Or just have your attribute expect a Permission instance instead ?
Mar 6, 2014 at 5:56 AM
Maybe it is possible, but I do not know how.

The code below returns 'An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type
[OrchardAuthorization(PermissionName = Orchard.Core.Contents.Permissions.PublishOwnContent.Name)]
The code below returns 'PermissionObject is not a valid named attribute argument because it is not a valid attribute parameter type
[OrchardAuthorization(PermissionObject = Orchard.Core.Contents.Permissions.PublishOwnContent)]
A piece of my code for the authorizationattribute
public class OrchardAuthorizationAttribute : AuthorizeAttribute
        public string PermissionName { get; set; }
        public Permission PermissionObject { get; set; }

        public override void OnAuthorization(AuthorizationContext filterContext)