Пример #1
0
        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);
        }
Пример #2
0
        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));
        }
Пример #3
0
		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;
		}
Пример #4
0
        /// <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);
        }
        /// <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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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]));
        }
Пример #9
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);
 }