| | |
| | | ap.permission = AccessPermission.NONE;
|
| | | ap.mutable = false;
|
| | |
|
| | | // determine maximum permission for the repository
|
| | | final AccessPermission maxPermission = |
| | | (repository.isFrozen || !repository.isBare) ?
|
| | | AccessPermission.CLONE : AccessPermission.REWIND;
|
| | |
|
| | | if (AccessRestrictionType.NONE.equals(repository.accessRestriction)) {
|
| | | // anonymous rewind
|
| | | ap.permissionType = PermissionType.ANONYMOUS;
|
| | | if (AccessPermission.REWIND.atMost(maxPermission)) {
|
| | | ap.permission = AccessPermission.REWIND;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | return ap;
|
| | | }
|
| | |
|
| | | // administrator
|
| | | if (canAdmin()) {
|
| | | ap.permissionType = PermissionType.ADMINISTRATOR;
|
| | | if (AccessPermission.REWIND.atMost(maxPermission)) {
|
| | | ap.permission = AccessPermission.REWIND;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | if (!canAdmin) {
|
| | | // administator permission from team membership
|
| | | for (TeamModel team : teams) {
|
| | |
| | | // repository owner - either specified owner or personal repository
|
| | | if (repository.isOwner(username) || repository.isUsersPersonalRepository(username)) {
|
| | | ap.permissionType = PermissionType.OWNER;
|
| | | if (AccessPermission.REWIND.atMost(maxPermission)) {
|
| | | ap.permission = AccessPermission.REWIND;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | return ap;
|
| | | }
|
| | |
|
| | | if (AuthorizationControl.AUTHENTICATED.equals(repository.authorizationControl) && isAuthenticated) {
|
| | | // AUTHENTICATED is a shortcut for authorizing all logged-in users RW+ access
|
| | | if (AccessPermission.REWIND.atMost(maxPermission)) {
|
| | | ap.permission = AccessPermission.REWIND;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | return ap;
|
| | | }
|
| | |
|
| | |
| | | AccessPermission p = permissions.get(repository.name.toLowerCase());
|
| | | if (p != null && repository.accessRestriction.isValidPermission(p)) {
|
| | | ap.permissionType = PermissionType.EXPLICIT;
|
| | | if (p.atMost(maxPermission)) {
|
| | | ap.permission = p;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | ap.mutable = true;
|
| | | return ap;
|
| | | }
|
| | |
| | | if (p != null && repository.accessRestriction.isValidPermission(p)) {
|
| | | // take first match
|
| | | ap.permissionType = PermissionType.REGEX;
|
| | | if (p.atMost(maxPermission)) {
|
| | | ap.permission = p;
|
| | | } else {
|
| | | ap.permission = maxPermission;
|
| | | }
|
| | | ap.source = key;
|
| | | return ap;
|
| | | }
|
| | |
| | | // try to find a team match
|
| | | for (TeamModel team : teams) {
|
| | | RegistrantAccessPermission p = team.getRepositoryPermission(repository);
|
| | | if (p.permission.exceeds(ap.permission) && PermissionType.ANONYMOUS != p.permissionType) {
|
| | | if (p.permission.atMost(maxPermission) && p.permission.exceeds(ap.permission) && PermissionType.ANONYMOUS != p.permissionType) {
|
| | | // use highest team permission that is not an implicit permission
|
| | | ap.permission = p.permission;
|
| | | ap.source = team.name;
|
| | |
| | | ap.permissionType = PermissionType.ANONYMOUS;
|
| | | break;
|
| | | case NONE:
|
| | | // implied REWIND or CLONE if frozen
|
| | | ap.permission = repository.isFrozen ? AccessPermission.CLONE : AccessPermission.REWIND;
|
| | | // implied REWIND or CLONE
|
| | | ap.permission = maxPermission;
|
| | | ap.permissionType = PermissionType.ANONYMOUS;
|
| | | break;
|
| | | }
|