public void CanMapFullPermission(Permission expectedPermission) { var map = new PermissionMap { Permissions = Permission.Full, Roles = new[] { "rolename" } }; Assert.That(map.MapsTo(expectedPermission), Is.True); Assert.That(map.Authorizes(user, item, expectedPermission), Is.True); }
public void CanMapReadPermission(Permission expectedPermission, bool expectedResult) { var map = new PermissionMap { Permissions = Permission.Read, Roles = new[] { "rolename" } }; Assert.That(map.MapsTo(expectedPermission), Is.EqualTo(expectedResult)); Assert.That(map.Authorizes(user, item, expectedPermission), Is.EqualTo(expectedResult)); }
public FileSystemRoot(string path, Site site) { Path = path; Readers = new PermissionMap(Permission.Read, new[] { "Administrators", "Editors", "Writers" }, new[] { "admin" }); Writers = new PermissionMap(Permission.Write, new[] { "Administrators", "Editors", "Writers" }, new[] { "admin" }); Site = site; }
/// <summary>Creates a new instance of the security manager.</summary> public SecurityManager(Web.IWebContext webContext, Configuration.EditSection config) { this.webContext = webContext; Administrators = config.Administrators.ToPermissionMap(Permission.Full, defaultAdministratorRoles, defaultAdministratorUsers); Editors = config.Editors.ToPermissionMap(Permission.ReadWritePublish, defaultEditorRoles, none); Writers = config.Writers.ToPermissionMap(Permission.ReadWrite, defaultWriterRoles, none); }
public SecurityManager(Web.IWebContext webContext) { this.webContext = webContext; Administrators = new PermissionMap(Permission.Full, defaultAdministratorRoles, defaultAdministratorUsers); Editors = new PermissionMap(Permission.ReadWritePublish, defaultEditorRoles, none); Writers = new PermissionMap(Permission.ReadWrite, defaultWriterRoles, none); }
private static bool IsAuthorized(object possiblySecurable, IPrincipal user, ContentItem item) { var securable = possiblySecurable as ISecurable; if (securable != null && securable.AuthorizedRoles != null && !PermissionMap.IsInRoles(user, securable.AuthorizedRoles)) { return(false); } return(true); }
public void CanClone() { PermissionMap original = new PermissionMap(Permission.ReadWrite, new string[] {"role1"}, new string[] {"user1"}); PermissionMap cloned = original.Clone(); Assert.That(original.Permissions, Is.EqualTo(cloned.Permissions)); Assert.That(original.Users.Length, Is.EqualTo(cloned.Users.Length)); Assert.That(original.Roles.Length, Is.EqualTo(cloned.Roles.Length)); Assert.That(original.Users[0], Is.EqualTo(cloned.Users[0])); Assert.That(original.Roles[0], Is.EqualTo(cloned.Roles[0])); }
protected Permission GetPermiossions(IPrincipal user, ContentItem item, PermissionMap map) { return map.Authorizes(user, item, map.Permissions) ? map.Permissions : Permission.None; }
private static void Apply(PermissionMap map, Directory dir) { if (map.IsAltered) DynamicPermissionMap.SetRoles(dir, map.Permissions, map.Roles); else DynamicPermissionMap.SetAllRoles(dir, map.Permissions); }
private Permission GetPermiossions(IPrincipal user, ContentItem item, PermissionMap map) { return(map.Authorizes(user, item, map.Permissions) ? map.Permissions : Permission.None); }