federationSets = \r
\r
#### Repository Names\r
-Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - .`<br/>\r
+Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - . ~`<br/>\r
Whitespace is illegal.\r
\r
Repositories can be grouped within subfolders. e.g. *libraries/mycoollib.git* and *libraries/myotherlib.git*\r
- **RWD** (clone and push with ref creation, deletion)\r
- **RW+** (clone and push with ref creation, deletion, rewind)\r
\r
+These permission codes are combined with the repository path to create a user permission:\r
+\r
+ RW:mygroup/myrepo.git\r
+\r
+#### Discrete Permissions with Regex Matching (Gitblit v1.2.0+)\r
+\r
+Gitblit also supports regex matching for repository permissions. The following permission grants push privileges to all repositories in the *mygroup* folder.\r
+\r
+ RW:mygroup/[A-Za-z0-9-~_\\./]+\r
+\r
#### No-So-Discrete Permissions (Gitblit <= v1.1.0)\r
\r
Prior to v1.2.0, Gitblit had two main access permission groupings: \r
[user "hannibal"]\r
password = bossman\r
repository = RWD:topsecret.git\r
+ repository = RW+:ateam/[A-Za-z0-9-~_\\./]+\r
\r
[user "faceman"]\r
password = vanity\r
- RWD (clone and push with ref creation, deletion)\r
- RW+ (clone and push with ref creation, deletion, rewind) \r
While not as sophisticated as Gitolite, this does give finer access controls. These permissions fit in cleanly with the existing users.conf and users.properties files. In Gitblit <= 1.1.0, all your existing user accounts have RW+ access. If you are upgrading to 1.2.0, the RW+ access is *preserved* and you will have to lower/adjust accordingly.\r
+- Implemented regex repository permission matching (issue 36) \r
+This allows you to specify a permission like `RW:mygroup/[A-Za-z0-9-~_\\./]+` to grant push privileges to all repositories within the *mygroup* project/folder.\r
- Added DELETE, CREATE, and NON-FAST-FORWARD ref change logging\r
- Added support for personal repositories. \r
Personal repositories can be created by accounts with the *create* permission and are stored in *git.repositoriesFolder/~username*. Each user with personal repositories will have a user page, something like the GitHub profile page. Personal repositories have all the same features as common repositories, except personal repositories can be renamed by their owner.\r
public AccessPermission getRepositoryPermission(RepositoryModel repository) {\r
AccessPermission permission = AccessPermission.NONE;\r
if (permissions.containsKey(repository.name.toLowerCase())) {\r
+ // exact repository permission specified\r
AccessPermission p = permissions.get(repository.name.toLowerCase());\r
if (p != null) {\r
permission = p;\r
}\r
+ } else {\r
+ // search for regex permission match\r
+ for (String key : permissions.keySet()) {\r
+ if (repository.name.matches(key)) {\r
+ AccessPermission p = permissions.get(key);\r
+ if (p != null) {\r
+ permission = p;\r
+ }\r
+ }\r
+ }\r
}\r
return permission;\r
}\r
// and the permissions of teams of which the user belongs\r
AccessPermission permission = AccessPermission.NONE;\r
if (permissions.containsKey(repository.name.toLowerCase())) {\r
+ // exact repository permission specified\r
AccessPermission p = permissions.get(repository.name.toLowerCase());\r
if (p != null) {\r
permission = p;\r
}\r
+ } else {\r
+ // search for regex permission match\r
+ for (String key : permissions.keySet()) {\r
+ if (repository.name.matches(key)) {\r
+ AccessPermission p = permissions.get(key);\r
+ if (p != null) {\r
+ permission = p;\r
+ }\r
+ }\r
+ }\r
}\r
\r
for (TeamModel team : teams) {\r
assertFalse("user CAN delete!", user.canDelete(repository));
assertFalse("user CAN edit!", user.canEdit(repository));
}
+
+ @Test
+ public void testWildcardMatching() throws Exception {
+ RepositoryModel repository = new RepositoryModel("ubercool/_my-r/e~po.git", null, null, new Date());
+ repository.authorizationControl = AuthorizationControl.NAMED;
+ repository.accessRestriction = AccessRestrictionType.VIEW;
+
+ UserModel user = new UserModel("test");
+ user.setRepositoryPermission("ubercool/[A-Za-z0-9-~_\\./]+", AccessPermission.CLONE);
+
+ assertTrue("user CAN NOT view!", user.canView(repository));
+ assertTrue("user CAN NOT clone!", user.canClone(repository));
+ assertFalse("user CAN push!", user.canPush(repository));
+
+ assertFalse("user CAN create ref!", user.canCreateRef(repository));
+ assertFalse("user CAN delete ref!", user.canDeleteRef(repository));
+ assertFalse("user CAN rewind ref!", user.canRewindRef(repository));
+
+ assertFalse("user CAN fork!", user.canFork(repository));
+
+ assertFalse("user CAN delete!", user.canDelete(repository));
+ assertFalse("user CAN edit!", user.canEdit(repository));
+
+ }
}