diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000..3fb584e --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.4 + + diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..023558b --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-Pmight-produce-incrementals +-Pconsume-incrementals diff --git a/pom.xml b/pom.xml index b651653..cd94eaa 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jenkins-ci.plugins plugin - 1.532 + 4.76 git-userContent @@ -15,7 +15,11 @@ This plugin manages JENKINS_HOME/userContent under Git - http://wiki.jenkins-ci.org/display/JENKINS/Git+userContent+Plugin + https://github.com/jenkinsci/git-userContent-plugin + + + 2.361.4 + scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git @@ -25,8 +29,7 @@ The MIT license - http://www.opensource.org/licenses/mit-license.php - repo + https://www.opensource.org/licenses/mit @@ -34,21 +37,26 @@ org.jenkins-ci.modules sshd - 1.1 - provided + 3.322.v159e91f6a_550 org.jenkins-ci.plugins git-server - 1.6 + 115.v132fd6e5777a_ repo.jenkins-ci.org - http://repo.jenkins-ci.org/public/ + https://repo.jenkins-ci.org/public/ + + + repo.jenkins-ci.org + https://repo.jenkins-ci.org/public/ + + diff --git a/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepository.java b/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepository.java index 99b47cc..f6f9cbe 100644 --- a/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepository.java +++ b/src/main/java/org/jenkinsci/plugins/gitUserContent/GitUserContentRepository.java @@ -1,13 +1,19 @@ package org.jenkinsci.plugins.gitUserContent; import hudson.Extension; -import hudson.model.RootAction; +import hudson.model.UnprotectedRootAction; +import hudson.security.ACL; +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; import jenkins.model.Jenkins; import org.jenkinsci.main.modules.sshd.SSHD; import org.jenkinsci.plugins.gitserver.FileBackedHttpGitRepository; import javax.inject.Inject; import java.io.File; +import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; /** * Exposes Git repository at http://server/jenkins/userContent.git @@ -15,7 +21,7 @@ * @author Kohsuke Kawaguchi */ @Extension -public class GitUserContentRepository extends FileBackedHttpGitRepository implements RootAction { +public class GitUserContentRepository extends FileBackedHttpGitRepository implements UnprotectedRootAction { @Inject public SSHD sshd; @@ -39,4 +45,15 @@ public String getDisplayName() { public String getUrlName() { return "userContent.git"; } + + @Override + public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { + if (!Jenkins.get().hasPermission(Jenkins.READ) && ACL.isAnonymous2(Jenkins.getAuthentication2())) { + rsp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + rsp.setHeader("WWW-Authenticate", "Basic realm=\"Jenkins user\""); + return; + } + Jenkins.get().checkPermission(Jenkins.READ); + super.doDynamic(req, rsp); + } } diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly new file mode 100644 index 0000000..4aa5f83 --- /dev/null +++ b/src/main/resources/index.jelly @@ -0,0 +1,4 @@ + +
+ This plugin manages JENKINS_HOME/userContent under Git. +