Security or better add authorize to Attributes

Feb 13, 2010 at 10:56 AM
Edited Feb 13, 2010 at 10:57 AM

There is a post but I've a better implementation. This need 3 lines of code but in the core!

1. Add Roles to IMvcSiteMapNodeAttribute.cs


string[] Roles { get; set; }

2. Add this to MvcSiteMapNodeAttribute.cs


public string[] Roles { get; set; }

3. Add this to the method GetMvcSiteMapNodeFromMvcSiteMapNodeAttribute of MvcSiteMapProvider.cs


// Set the properties on siteMapNode.
siteMapNode.Roles = attribute.Roles;

Now in the controller you can add something like:


[MvcSiteMap.Core.MvcSiteMapNode(Title = "List", ParentKey = "Home", Key = "Events", Roles = new[] { "Administrator", "Other" })]

Hope to see this in the trunk. 





Feb 22, 2010 at 1:15 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.