Skip to content

Commit

Permalink
Allow to work with CSR protection
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Belzunce Arcos authored and Felix Belzunce Arcos committed Sep 16, 2015
1 parent faef845 commit cb8447f
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/org/jenkinsci/plugins/ghprb/GhprbCrumbExclusion.java
@@ -0,0 +1,33 @@
package org.jenkinsci.plugins.ghprb;

import hudson.Extension;
import hudson.security.csrf.CrumbExclusion;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* Excludes {@link GhprbRootAction} from the CSRF protection.
* @since 1.28
*/
@Extension
public class GhprbCrumbExclusion extends CrumbExclusion {

@Override
public boolean process(HttpServletRequest req, HttpServletResponse resp, FilterChain chain)
throws IOException, ServletException {
final String pathInfo = req.getPathInfo();
if (pathInfo != null && pathInfo.startsWith(getExclusionPath())) {
chain.doFilter(req, resp);
return true;
}
return false;
}

public String getExclusionPath() {
return "/" + GhprbRootAction.URL + "/";
}
}

0 comments on commit cb8447f

Please sign in to comment.