HttpFirewall阻止了UrlEncodedSlash(Grails 3.3.0.RC1;Spring安全核心3.2.0.M1)

HttpFirewall阻止了UrlEncodedSlash(Grails 3.3.0.RC1;Spring安全核心3.2.0.M1),grails,spring-security,grails3,Grails,Spring Security,Grails3,我在日志中发现以下错误: 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.springframe

我在日志中发现以下错误:

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中有效。

我可以,以及如何在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'

有什么遗漏或错误吗?

默认情况下,spring security核心插件使用
DefaultHttpFirewall
您可以通过扩展
DefaultHttpFirewall
来创建一个子类,并从构造函数中将属性
AllowUncoredSlash
设置为true

 CustomHttpFirewall extends DefaultHttpFirewall {
   CustomHttpFirewall() {
     allowUrlEncodedSlash = true
   }
}
然后将spring security配置为使用自定义防火墙类,如下所示

grails.plugin.springsecurity.httpFirewallBeanClass = "full name of your class"

注意:已测试,但这应该可以工作。

听起来很合理,我能够实现它。只要我能够在生产环境中证明解决方案,我就会奖励奖金,因为错误只发生在生产环境中。提前多谢!嗨,Sudhir,我编辑了这个问题,并描述了我是如何实施你的建议的。有什么遗漏吗?嗨,Sundhir,虽然我无法在高效的环境中测试您的最后一条评论,但我授予您奖金。如果我能验证解决方案是否有效,我也会在以后接受答案。不管怎样,提前谢谢你!不用担心,如果您仍然无法将其发送到WorkID,请进行注释。您可以尝试在调试器中调试它,以确保您的自定义防火墙已使用且AllowUncordedslash为真?我尝试过,但我不知道在何处设置断点以及在何处查看是否使用了CustomHttpFirewall。如果我在CustomHttpFirewall类中设置断点,这至少还不止于此,这意味着你的自定义类没有被使用。将断点放在SpringSecurityCoreGrailsPlugin的doWithSpring中——我终于能够使类被调用。现在,每当我在spring安全配置期间部署war文件(或运行项目)时,断点都会触发。但是,错误日志仍然显示相同的错误。。。