| | |
| | | // Git Servlet disabled
|
| | | return false;
|
| | | }
|
| | | boolean readOnly = repository.isFrozen; |
| | | if (readOnly || repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) {
|
| | | boolean authorizedUser = user.canAccessRepository(repository);
|
| | | if (action.equals(gitReceivePack)) {
|
| | | // Push request
|
| | | if (!readOnly && authorizedUser) {
|
| | | // clone-restricted or push-authorized
|
| | | if (user.canPush(repository)) {
|
| | | return true;
|
| | | } else {
|
| | | // user is unauthorized to push to this repository
|
| | |
| | | }
|
| | | } else if (action.equals(gitUploadPack)) {
|
| | | // Clone request
|
| | | boolean cloneRestricted = repository.accessRestriction
|
| | | .atLeast(AccessRestrictionType.CLONE);
|
| | | if (!cloneRestricted || (cloneRestricted && authorizedUser)) {
|
| | | // push-restricted or clone-authorized
|
| | | if (user.canClone(repository)) {
|
| | | return true;
|
| | | } else {
|
| | | // user is unauthorized to clone this repository
|
| | | logger.warn(MessageFormat.format("user {0} is not authorized to clone {1}",
|
| | | user.username, repository));
|
| | | return false;
|
| | | }
|
| | | }
|
| | | }
|
| | | return true;
|