| | |
| | | import com.gitblit.models.RepositoryModel; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.transport.git.GitDaemonClient; |
| | | import com.gitblit.transport.ssh.SshSession; |
| | | import com.gitblit.transport.ssh.SshDaemonClient; |
| | | import com.gitblit.utils.HttpUtils; |
| | | import com.gitblit.utils.StringUtils; |
| | | |
| | |
| | | |
| | | if (req instanceof HttpServletRequest) { |
| | | // http/https request may or may not be authenticated |
| | | HttpServletRequest request = (HttpServletRequest) req; |
| | | repositoryName = request.getAttribute("gitblitRepositoryName").toString(); |
| | | origin = request.getRemoteHost(); |
| | | gitblitUrl = HttpUtils.getGitblitURL(request); |
| | | HttpServletRequest client = (HttpServletRequest) req; |
| | | repositoryName = client.getAttribute("gitblitRepositoryName").toString(); |
| | | origin = client.getRemoteHost(); |
| | | gitblitUrl = HttpUtils.getGitblitURL(client); |
| | | |
| | | // determine pushing user |
| | | String username = request.getRemoteUser(); |
| | | String username = client.getRemoteUser(); |
| | | if (!StringUtils.isEmpty(username)) { |
| | | UserModel u = gitblit.getUserModel(username); |
| | | if (u != null) { |
| | |
| | | |
| | | // set timeout from Git daemon |
| | | timeout = client.getDaemon().getTimeout(); |
| | | } else if (req instanceof SshSession) { |
| | | } else if (req instanceof SshDaemonClient) { |
| | | // SSH request is always authenticated |
| | | SshSession s = (SshSession) req; |
| | | repositoryName = s.getRepositoryName(); |
| | | origin = s.getRemoteAddress().toString(); |
| | | String username = s.getRemoteUser(); |
| | | user = gitblit.getUserModel(username); |
| | | SshDaemonClient client = (SshDaemonClient) req; |
| | | repositoryName = client.getRepositoryName(); |
| | | origin = client.getRemoteAddress().toString(); |
| | | user = client.getUser(); |
| | | } |
| | | |
| | | boolean allowAnonymousPushes = settings.getBoolean(Keys.git.allowAnonymousPushes, false); |