Add a CrumbExclusion for the /project/ path

This commit is contained in:
Ugo Méda 2014-10-06 10:53:32 +02:00
parent c91de8bfb5
commit dec7f78a6c
1 changed files with 22 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import hudson.plugins.git.GitSCM;
import hudson.plugins.git.util.BuildData;
import hudson.scm.SCM;
import hudson.security.ACL;
import hudson.security.csrf.CrumbExclusion;
import hudson.util.HttpResponses;
import java.io.IOException;
@ -26,7 +27,10 @@ import java.util.ListIterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
@ -415,4 +419,21 @@ public class GitLabWebHook implements UnprotectedRootAction {
}
@Extension
public static class GitlabWebHookCrumbExclusion extends CrumbExclusion {
@Override
public boolean process(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException {
String pathInfo = req.getPathInfo();
if (pathInfo != null && pathInfo.startsWith(getExclusionPath())) {
chain.doFilter(req, resp);
return true;
}
return false;
}
private String getExclusionPath() {
return '/' + WEBHOOK_URL + '/';
}
}
}