본문 바로가기
spring/spring security

[spring security] URL 더블슬래시 허용 - The request was rejected because the URL was not normalized.

by moonsiri 2020. 10. 14.
728x90
반응형

Spring security의 기본정책은 URL에 더블 슬래시가 들어가는 것을 허용하지 않습니다.

 

예를 들어 https://moonsiri.tistory.com/category와 같은 URL을 사용할 때, URL 더블 슬래시 처리가 안되어있는 상태에서 https://moonsiri.tistory.com//category로 요청이 들어오면 에러가 발생합니다.

org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL was not normalized.
	at org.springframework.security.web.firewall.StrictHttpFirewall.getFirewalledRequest(StrictHttpFirewall.java:296)

 

만약 더블 슬래시를 허용하고 싶다면 아래와 같이 HttpFirewall Bean을 등록해주면 됩니다.

@Bean
public HttpFirewall defaultHttpFirewall() {
    return new DefaultHttpFirewall();
}

 

 

[Reference]

https://stackoverflow.com/questions/48453980/spring-5-0-3-requestrejectedexception-the-request-was-rejected-because-the-url

728x90
반응형

댓글