\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
+Gitblit also supports *case-insensitive* 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
+ RW:mygroup/[a-z0-9-~_\\./]+\r
\r
#### No-So-Discrete Permissions (Gitblit <= v1.1.0)\r
\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
+- Implemented *case-insensitive* regex repository permission matching (issue 36) \r
+This allows you to specify a permission like `RW:mygroup/[a-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
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.Constants.RegistrantType;\r
import com.gitblit.Constants.Unused;\r
+import com.gitblit.utils.StringUtils;\r
\r
/**\r
* TeamModel is a serializable model class that represents a group of users and\r
permission = p;\r
}\r
} else {\r
- // search for regex permission match\r
+ // search for case-insensitive regex permission match\r
for (String key : permissions.keySet()) {\r
- if (repository.name.matches(key)) {\r
+ if (StringUtils.matchesIgnoreCase(repository.name, key)) {\r
AccessPermission p = permissions.get(key);\r
if (p != null) {\r
permission = p;\r
return p;\r
}\r
} else {\r
- // search for regex permission match\r
+ // search for case-insensitive regex permission match\r
for (String key : permissions.keySet()) {\r
- if (repository.name.matches(key)) {\r
+ if (StringUtils.matchesIgnoreCase(repository.name, key)) {\r
AccessPermission p = permissions.get(key);\r
if (p != null) {\r
permission = p;\r
}\r
return path;\r
}\r
+ \r
+ /**\r
+ * Variation of String.matches() which disregards case issues.\r
+ * \r
+ * @param regex\r
+ * @param input\r
+ * @return true if the pattern matches\r
+ */\r
+ public static boolean matchesIgnoreCase(String input, String regex) {\r
+ Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);\r
+ Matcher m = p.matcher(input);\r
+ return m.matches();\r
+ }\r
}
\ No newline at end of file
repository.accessRestriction = AccessRestrictionType.VIEW;
UserModel user = new UserModel("test");
- user.setRepositoryPermission("ubercool/[A-Za-z0-9-~_\\./]+", AccessPermission.CLONE);
+ user.setRepositoryPermission("ubercool/[A-Z0-9-~_\\./]+", AccessPermission.CLONE);
assertTrue("user DOES NOT HAVE a repository permission!", user.hasRepositoryPermission(repository.name));
assertTrue("user CAN NOT view!", user.canView(repository));