diff --git a/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java b/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java new file mode 100644 index 00000000..dff0596a --- /dev/null +++ b/wise-webapp/src/main/java/com/wisemapping/security/CSFRRequestMatcher.java @@ -0,0 +1,27 @@ +package com.wisemapping.security; + +import org.springframework.security.web.util.matcher.RequestMatcher; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; + +public class CSFRRequestMatcher implements RequestMatcher { + + private String prefix; + static String[] supportedMethods = {"POST", "PUT", "GET", "DELETE", "PATCH"}; + + @Override + public boolean matches(HttpServletRequest request) { + final String requestURI = request.getRequestURI(); + return Arrays.stream(supportedMethods).anyMatch(p -> request.getMethod().toUpperCase().equals(p)) + && requestURI.startsWith(prefix); + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } +} diff --git a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml index da13fe3d..e75ddd93 100644 --- a/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml +++ b/wise-webapp/src/main/webapp/WEB-INF/wisemapping-security.xml @@ -42,7 +42,7 @@ - + @@ -62,8 +62,6 @@ - - - + - - + + +