Spring security DefaultHttpFirewall - The requestURI cannot contain encoded slash

后端 未结 1 792
半阙折子戏
半阙折子戏 2021-02-06 07:51

In a spring-boot with security enabled web app, I\'m getting the following error when performing a GET request which contains an encoded slash

http://172.16.62.11:8080/c

相关标签:
1条回答
  • 2021-02-06 08:09

    Found out the issue - apparently in latest release of spring security, the usage of encoded slashes in url has been blocked

    https://github.com/spring-projects/spring-security/commit/666e356ebc479194ba51e43bb99fc42f849b6175

    To overcome this, provide your own HttpFirewall implementation to WebSecurity as follows

    @Bean
    public HttpFirewall allowUrlEncodedSlashHttpFirewall() {
        DefaultHttpFirewall firewall = new DefaultHttpFirewall();
        firewall.setAllowUrlEncodedSlash(true);
        return firewall;
    }
    
    @Override
    public void configure(WebSecurity web) throws Exception {
        web.httpFirewall(allowUrlEncodedSlashHttpFirewall());
    }
    
    0 讨论(0)
提交回复
热议问题