Try regex permission matching if exact permission is not found (issue-36)
| | |
| | | federationSets =
|
| | |
|
| | | #### Repository Names
|
| | | Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - .`<br/>
|
| | | Repository names must be unique and are CASE-SENSITIVE ON CASE-SENSITIVE FILESYSTEMS. The name must be composed of letters, digits, or `/ _ - . ~`<br/>
|
| | | Whitespace is illegal.
|
| | |
|
| | | Repositories can be grouped within subfolders. e.g. *libraries/mycoollib.git* and *libraries/myotherlib.git*
|
| | |
| | | - **RWC** (clone and push with ref creation)
|
| | | - **RWD** (clone and push with ref creation, deletion)
|
| | | - **RW+** (clone and push with ref creation, deletion, rewind)
|
| | |
|
| | | These permission codes are combined with the repository path to create a user permission:
|
| | |
|
| | | RW:mygroup/myrepo.git
|
| | |
|
| | | #### Discrete Permissions with Regex Matching (Gitblit v1.2.0+)
|
| | |
|
| | | Gitblit also supports regex matching for repository permissions. The following permission grants push privileges to all repositories in the *mygroup* folder.
|
| | |
|
| | | RW:mygroup/[A-Za-z0-9-~_\\./]+
|
| | |
|
| | | #### No-So-Discrete Permissions (Gitblit <= v1.1.0)
|
| | |
|
| | |
| | | [user "hannibal"]
|
| | | password = bossman
|
| | | repository = RWD:topsecret.git
|
| | | repository = RW+:ateam/[A-Za-z0-9-~_\\./]+
|
| | |
|
| | | [user "faceman"]
|
| | | password = vanity
|
| | |
| | | - RWD (clone and push with ref creation, deletion)
|
| | | - RW+ (clone and push with ref creation, deletion, rewind)
|
| | | 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.
|
| | | - Implemented regex repository permission matching (issue 36) |
| | | 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.
|
| | | - Added DELETE, CREATE, and NON-FAST-FORWARD ref change logging
|
| | | - Added support for personal repositories.
|
| | | 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.
|
| | |
| | | public AccessPermission getRepositoryPermission(RepositoryModel repository) {
|
| | | AccessPermission permission = AccessPermission.NONE;
|
| | | if (permissions.containsKey(repository.name.toLowerCase())) {
|
| | | // exact repository permission specified
|
| | | AccessPermission p = permissions.get(repository.name.toLowerCase());
|
| | | if (p != null) {
|
| | | permission = p;
|
| | | }
|
| | | } else {
|
| | | // search for regex permission match
|
| | | for (String key : permissions.keySet()) {
|
| | | if (repository.name.matches(key)) {
|
| | | AccessPermission p = permissions.get(key);
|
| | | if (p != null) {
|
| | | permission = p;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | return permission;
|
| | | }
|
| | |
| | | // and the permissions of teams of which the user belongs
|
| | | AccessPermission permission = AccessPermission.NONE;
|
| | | if (permissions.containsKey(repository.name.toLowerCase())) {
|
| | | // exact repository permission specified
|
| | | AccessPermission p = permissions.get(repository.name.toLowerCase());
|
| | | if (p != null) {
|
| | | permission = p;
|
| | | }
|
| | | } else {
|
| | | // search for regex permission match
|
| | | for (String key : permissions.keySet()) {
|
| | | if (repository.name.matches(key)) {
|
| | | AccessPermission p = permissions.get(key);
|
| | | if (p != null) {
|
| | | permission = p;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | for (TeamModel team : teams) {
|
| | |
| | | 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)); |
| | | |
| | | } |
| | | } |