diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2018-01-28 11:26:25 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2018-01-28 11:26:25 +0300 |
commit | 7149adb8be3ed1c8774bf9100848fc8589e3fd18 (patch) | |
tree | 33fd5a74f7c927b4b3e88b8051927f0d2e643084 | |
parent | f0b4a844736238e19542f56ec9ae9fdcf5463424 (diff) | |
download | bbprb-7149adb8be3ed1c8774bf9100848fc8589e3fd18.tar.gz |
Add crumb exclusion for /bbprb-hook/
-rw-r--r-- | src/main/java/org/jenkinsci/plugins/bbprb/BitbucketHookReceiver.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketHookReceiver.java b/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketHookReceiver.java index 18b2688..3562a7e 100644 --- a/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketHookReceiver.java +++ b/src/main/java/org/jenkinsci/plugins/bbprb/BitbucketHookReceiver.java @@ -3,6 +3,7 @@ package org.jenkinsci.plugins.bbprb; import hudson.Extension; import hudson.model.UnprotectedRootAction; import hudson.security.ACL; +import hudson.security.csrf.CrumbExclusion; import hudson.triggers.Trigger; import hudson.triggers.TriggerDescriptor; import java.io.IOException; @@ -12,6 +13,10 @@ import java.util.List; import java.util.Map; 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 jenkins.model.ParameterizedJobMixIn.ParameterizedJob; import net.sf.json.JSONException; @@ -23,11 +28,24 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @Extension -public class BitbucketHookReceiver implements UnprotectedRootAction { +public class BitbucketHookReceiver + extends CrumbExclusion implements UnprotectedRootAction { private static final String BITBUCKET_HOOK_URL = "bbprb-hook"; private static final String BITBUCKET_UA = "Bitbucket-Webhooks/2.0"; + @Override + public boolean process(HttpServletRequest req, HttpServletResponse resp, + FilterChain chain) + throws IOException, ServletException { + String pathInfo = req.getPathInfo(); + if (pathInfo != null && pathInfo.startsWith("/" + BITBUCKET_HOOK_URL)) { + chain.doFilter(req, resp); + return true; + } + return false; + } + public void doIndex(StaplerRequest req, StaplerResponse resp) throws IOException { |