Permissions configuration
The security configuration information is stored in the SecurityConfig class.
To use the security configuration information, you must add the following namespace to your class:
using Telerik.Sitefinity.Security.Configuration;
The following code initializes the SecurityConfig class:
SecurityConfig secConfig = Config.Get<SecurityConfig>();
The configuration information for the permission sets is persisted in the Permissions property of the SecurityConfig class. To get configuration information for a permission set, you use the following code:
SecurityConfig secConfig = Config.Get<SecurityConfig>();
Telerik.Sitefinity.Security.Configuration.Permission blogsPermissions = secConfig.Permissions[SecurityConstants.Sets.Blog.SetName];
The Telerik.Sitefinity.Security.SecurityConstants.Sets class contains the names of all permission sets.
In the above example, first, you initialize the SecurityConfig class. The Permissions property is a dictionary that accepts the permission set name as key. To get the blogs permission set, you use SecurityConstants.Sets.Blog.SetName as key.
The permission sets that the Permissions property stores contain all configuration information about the actions that can be granted or denied for the given set of objects. In the above example, blogsPermissions contains all actions that can be performed on blogs. You use the actions when creating permission associated with a permission set and granting and denying it for the principal. For more information, see Granting and denying permissions.
The following example initializes the view action for the blogs:
SecurityAction view = blogsPermissions.Actions[SecurityConstants.Sets.Blog.View];
The action is stored in the SecurityAction class. The Actions property of the Permission class is a dictionary that accepts the action name as key. To get the view action for the blog, you use SecurityConstants.Sets.Blog.View as key.
An action in Sitefinity is characterized with a set of properties.
- Name
The name of the action.
- Title
The title of the action.
- Description
The description of the action.
- Value
The value of the action. The actions in the permission set have specific order (starting from 0) that defines their value using the equation action value = 2ordinal. When creating permission, you use the Value property to create the proper bit mask to grant or deny the action. For more information, see Permissions and Granting and denying permissions.
See also
Permissions
Granting and denying permissions