public
override
void
SetRootPermissions(SecurityRoot root)
{
if
(root.Permissions !=
null
|| root.Permissions.Count > 0)
{
root.Permissions.Clear();
}
var appRoles = Config.Get<SecurityConfig>().ApplicationRoles;
var everyoneRoleId = appRoles[SecurityConstants.AppRoles.Everyone].Id;
var authorsRoleId = appRoles[SecurityConstants.AppRoles.Authors].Id;
var editorsRoleId = appRoles[SecurityConstants.AppRoles.Editors].Id;
// Products
var permissionsforEveryoneToViewProducts =
this
.CreatePermission(ProductsConstants.Security.PermissionSetName, root.Id, everyoneRoleId);
permissionsforEveryoneToViewProducts.GrantActions(
false
, ProductsConstants.Security.View);
root.Permissions.Add(permissionsforEveryoneToViewProducts);
var permissionsForOwnersToModifyAndDeleteProducts =
this
.CreatePermission(ProductsConstants.Security.PermissionSetName, root.Id, SecurityManager.OwnerRole.Id);
permissionsForOwnersToModifyAndDeleteProducts.GrantActions(
false
, ProductsConstants.Security.Modify, ProductsConstants.Security.Delete);
root.Permissions.Add(permissionsForOwnersToModifyAndDeleteProducts);
var editorsPermissionsForProducts =
this
.CreatePermission(ProductsConstants.Security.PermissionSetName, root.Id, editorsRoleId);
editorsPermissionsForProducts.GrantActions(
false
,
ProductsConstants.Security.Create,
ProductsConstants.Security.Modify,
ProductsConstants.Security.Delete,
ProductsConstants.Security.ChangeOwner);
root.Permissions.Add(editorsPermissionsForProducts);
var authorsPermissionsForProducts =
this
.CreatePermission(ProductsConstants.Security.PermissionSetName, root.Id, authorsRoleId);
authorsPermissionsForProducts.GrantActions(
false
, ProductsConstants.Security.Create);
root.Permissions.Add(authorsPermissionsForProducts);
}