public bool AllowCreateApplication(string application) { if (string.IsNullOrWhiteSpace(application)) { return(false); } return(User.IsInRole(SecurityRoles.RoleCreateApplication()) || IsMasterKey); }
public bool AllowCreateDirectories(string application, string directoryName) { if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName)) { return(false); } return(User.IsInRole(SecurityRoles.RoleCreateDirectory(application)) || IsMasterKey); }
public bool AllowReadApiKeys(string applicationName) { if (string.IsNullOrWhiteSpace(applicationName)) { return(false); } return(User.IsInRole(SecurityRoles.RoleReadApiKeys(applicationName)) || IsMasterKey); }
public bool AllowDeleteSetting(string application, string directoryName) { if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName)) { return(false); } return(User.IsInRole(SecurityRoles.RoleDeleteSetting(application, directoryName)) || IsMasterKey); }
public bool AllowDeleteApplication(string application) { if (string.IsNullOrWhiteSpace(application) || string.Equals(application, Constants.SYSTEM_APPLICATION_NAME, System.StringComparison.CurrentCultureIgnoreCase)) { return(false); } return(User.IsInRole(SecurityRoles.RoleDeleteApplication(application)) || IsMasterKey); }
public static string[] ConstructRoles(string strKey) { List <string> roles = new List <string>(); using (ValidationRepository repository = new ValidationRepository()) { ApiKeyData data = repository.GetApiKey(strKey); if (data != null && data.Active) { bool allowAdministration = data.AdminKey || data.Id == Constants.SYSTEM_MASTER_KEY_ID; roles.Add(SecurityRoles.RoleReadDirectories(data.Application.Name)); roles.Add(SecurityRoles.RoleReadVersions(data.Application.Name)); if (data.Id == Constants.SYSTEM_MASTER_KEY_ID) { roles.Add(SecurityRoles.RoleCreateApplication()); roles.Add(SecurityRoles.RoleDeleteApplication(data.Application.Name)); roles.Add(SecurityRoles.RoleReadApiKeys()); } foreach (var item in data.Access) { if (allowAdministration) { AddRoles(SecurityRoles.RoleDeleteDirectory(item.Directory.Application.Name, item.Directory.Name), roles); AddRoles(SecurityRoles.RoleCreateDirectory(item.Directory.Application.Name), roles); AddRoles(SecurityRoles.RoleDeleteDirectories(item.Directory.Application.Name), roles); AddRoles(SecurityRoles.RoleCreateVersion(item.Directory.Application.Name), roles); AddRoles(SecurityRoles.RoleDeleteVersion(item.Directory.Application.Name), roles); AddRoles(SecurityRoles.RoleEditApiKey(item.Directory.Application.Name), roles); AddRoles(SecurityRoles.RoleReadApiKeys(item.Directory.Application.Name), roles); } AddRoles(SecurityRoles.RoleReadDirectory(item.Directory.Application.Name, item.Directory.Name), roles); if (item.AllowCreate) { AddRoles(SecurityRoles.RoleCreateSetting(item.Directory.Application.Name, item.Directory.Name), roles); } if (item.AllowDelete) { AddRoles(SecurityRoles.RoleDeleteSetting(item.Directory.Application.Name, item.Directory.Name), roles); } if (item.AllowWrite) { AddRoles(SecurityRoles.RoleWriteSetting(item.Directory.Application.Name, item.Directory.Name), roles); } } } return(roles.ToArray()); } }
public bool AllowCreateDirectory(string application, string directoryName) { if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName)) { return(false); } if (!string.IsNullOrWhiteSpace(directoryName)) { if (string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase)) { return(false); } return(User.IsInRole(SecurityRoles.RoleCreateDirectory(application))); } return(false); }
public bool AllowDeleteDirectory(string application, string directoryName) { if (string.IsNullOrWhiteSpace(application) || string.IsNullOrWhiteSpace(directoryName)) { return(false); } if (!IsMasterKey && string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase)) { return(false); } if (string.Equals(application, Constants.SYSTEM_APPLICATION_NAME, System.StringComparison.CurrentCultureIgnoreCase) && string.Equals(directoryName, Constants.DEAULT_DIRECTORY_NAME, System.StringComparison.CurrentCultureIgnoreCase)) { return(false); } return(User.IsInRole(SecurityRoles.RoleDeleteDirectory(application, directoryName)) || IsMasterKey); }