我在日志中发现了这个错误:
org.springframework.security.web.firewall.RequestRejectedException: The requestURI cannot contain encoded slash. Got /;lm=1488887514;m=js;asset=delayedElements%2Fsnippet;tf;ucm=353df4434086482d9d1d7b89758e156e/
at org.springframework.security.web.firewall.DefaultHttpFirewall.getFirewalledRequest(DefaultHttpFirewall.java:56)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:193)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
...
我发现这个解决方案可能适用于Spring Boot。 Spring security DefaultHttpFirewall - The requestURI cannot contain encoded slash
我可以,以及如何在Grails中应用它? 非常感谢提前!
编辑1:
这是我实施Sudhir建议的方式:
我在这里创建了新类:
这是实现的样子:
package fnx.security;
import org.springframework.security.web.firewall.DefaultHttpFirewall;
public class CustomHttpFirewall extends DefaultHttpFirewall {
CustomHttpFirewall() {
boolean allowUrlEncodedSlash = true;
}
}
这就是它包含在application.yml中的方式:
grails:
plugin:
springsecurity:
httpFirewallBeanClass: 'fnx.security.CustomHttpFirewall'
有什么遗漏或错误吗?
答案 0 :(得分:3)
默认情况下,spring security core plugin使用DefaultHttpFirewall
您可以通过扩展DefaultHttpFirewall
创建子类,并将属性allowUrlEncodedSlash
设置为true。
CustomHttpFirewall extends DefaultHttpFirewall {
CustomHttpFirewall() {
allowUrlEncodedSlash = true
}
}
然后配置spring security以使用您的自定义防火墙类,如下所示。
grails.plugin.springsecurity.httpFirewallBeanClass = "full name of your class"
注意测试,但这应该有效。