public static IPermissionPolicyUser GetAnonymousPermissionPolicyUser(this IPermissionPolicyRole systemRole) { var optionsAthentication = ((IModelOptionsAuthentication)ApplicationHelper.Instance.Application.Model.Options).Athentication; var anonymousUserName = optionsAthentication.AnonymousAuthentication.AnonymousUser; return((IPermissionPolicyUser)systemRole.GetPermissionPolicyUser(anonymousUserName)); }
private List <string> GetCodeLinesFromRole(IPermissionPolicyRole role) { List <string> codeLines = new List <string>(); if (role != null) { codeLines.Add($"role.Name = \"{role.Name}\";"); codeLines.Add($"role.PermissionPolicy = SecurityPermissionPolicy.{role.PermissionPolicy.ToString()};"); if (role.IsAdministrative) { codeLines.Add($"role.IsAdministrative = true;"); } if (role.CanEditModel) { codeLines.Add($"role.CanEditModel = true;"); } if (CustomizeCodeLines != null) { List <string> customCodeLines = new List <string>(); CustomizeCodeLines(this, new CustomizeCodeLinesEventArg(role, customCodeLines)); codeLines.AddRange(customCodeLines); } foreach (IPermissionPolicyTypePermissionObject typePermissionObject in role.TypePermissions) { codeLines.AddRange(GetCodeLinesFromTypePermissionObject(typePermissionObject)); } if (role is INavigationPermissions navigationPermissionsRole) { foreach (IPermissionPolicyNavigationPermissionObject navigationPermissionObject in navigationPermissionsRole.NavigationPermissions) { string codeLine = GetCodeLine(navigationPermissionObject); if (codeLine != string.Empty) { codeLines.Add(codeLine); } } } if (role is IActionPermissions actionPermissionsRole) { foreach (IPermissionPolicyActionPermissionObject actionPermissionsObject in actionPermissionsRole.ActionPermissions) { string codeLine = GetCodeLine(actionPermissionsObject); if (codeLine != string.Empty) { codeLines.Add(codeLine); } } } } return(codeLines); }
static IPermissionPolicyObjectPermissionsObject AddObjectPermission(this IPermissionPolicyRole role, Type type, string operations, string criteria, SecurityPermissionState?state) => (IPermissionPolicyObjectPermissionsObject)PermissionSettingHelperType .Method(nameof(AddObjectPermission), new[] { typeof(IPermissionPolicyRole), typeof(Type), typeof(string), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic) .Call(null, role, type, operations, criteria, state);
static IPermissionPolicyNavigationPermissionObject AddNavigationPermission( this IPermissionPolicyRole role, string itemPath, SecurityPermissionState?state) => (IPermissionPolicyNavigationPermissionObject)PermissionSettingHelperType.Method(nameof(AddNavigationPermission), new [] { typeof(IPermissionPolicyRole), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic) .Call(null, role, itemPath, state);
static void AddTypePermissionsRecursively(this IPermissionPolicyRole role, Type targetType, string operations, SecurityPermissionState?state) => PermissionSettingHelperType .Method(nameof(AddTypePermissionsRecursively), new[] { typeof(IPermissionPolicyRole), typeof(Type), typeof(string), typeof(SecurityPermissionState) }, Flags.StaticPublic) .Call(null, role, targetType, operations, state);
void SetPermissions(IPermissionPolicyRole employersRole) { employersRole.SetTypePermission <ReportData>(SecurityOperations.ReadOnlyAccess, SecurityPermissionState.Allow); ((ISecurityRole)employersRole).CreatePermissionBehaviour(PermissionBehavior.ReadOnlyAccess, (role, info) => ((IPermissionPolicyRole)role).SetTypePermission(info.Type, SecurityOperations.ReadOnlyAccess, SecurityPermissionState.Allow)); }
public CustomizeCodeLinesEventArg(IPermissionPolicyRole role, List <string> customCodeLines) { Role = role; CustomCodeLines = customCodeLines; }
void ICustomPermissionPolicyUser.SetUserRole(IPermissionPolicyRole role) { Roles.Add((PermissionPolicyRole)role); }
public static ISecurityUserWithRoles GetPermissionPolicyUser(this IPermissionPolicyRole systemRole, string userName, string passWord = "") { var objectSpace = XPObjectSpace.FindObjectSpaceByObject(systemRole); return(objectSpace.GetUser(userName, passWord, (ISecurityRole)systemRole)); }
public static ISecurityUserWithRoles GetAnonymousPermissionPolicyUser(this IPermissionPolicyRole systemRole, string userName) { return(systemRole.GetPermissionPolicyUser(userName)); }