| | |
| | | return this; |
| | | } |
| | | |
| | | public boolean isServingRepositories() { |
| | | return settings.getBoolean(Keys.git.enableGitServlet, true) |
| | | || (gitDaemon != null && gitDaemon.isRunning()) |
| | | || (sshDaemon != null && sshDaemon.isRunning()); |
| | | } |
| | | |
| | | protected void configureFederation() { |
| | | boolean validPassphrase = true; |
| | | String passphrase = settings.getString(Keys.federation.passphrase, ""); |
| | |
| | | } |
| | | |
| | | public String getSshDaemonUrl(HttpServletRequest request, UserModel user, RepositoryModel repository) { |
| | | if (user == null || UserModel.ANONYMOUS.equals(user)) { |
| | | // SSH always requires authentication - anonymous access prohibited |
| | | return null; |
| | | } |
| | | if (sshDaemon != null) { |
| | | String bindInterface = settings.getString(Keys.git.sshBindInterface, "localhost"); |
| | | if (bindInterface.equals("localhost") |
| | |
| | | return null; |
| | | } |
| | | |
| | | public AccessPermission getSshDaemonAccessPermission(UserModel user, RepositoryModel repository) { |
| | | if (sshDaemon != null && user.canClone(repository)) { |
| | | AccessPermission sshDaemonPermission = user.getRepositoryPermission(repository).permission; |
| | | if (sshDaemonPermission.atLeast(AccessPermission.CLONE)) { |
| | | if (repository.accessRestriction.atLeast(AccessRestrictionType.CLONE)) { |
| | | // can not authenticate clone via anonymous ssh protocol |
| | | sshDaemonPermission = AccessPermission.NONE; |
| | | } else if (repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) { |
| | | // can not authenticate push via anonymous ssh protocol |
| | | sshDaemonPermission = AccessPermission.CLONE; |
| | | } else { |
| | | // normal user permission |
| | | } |
| | | } |
| | | return sshDaemonPermission; |
| | | } |
| | | return AccessPermission.NONE; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Extract the hostname from the canonical url or return the |
| | | * hostname from the servlet request. |
| | | * |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |