From 451a462996c7b4d55cd2461f961defe11cc4e136 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 14 Nov 2021 17:53:35 +0300 Subject: Handle rejected requests with error 400 --- src/main/java/com/juick/config/WebConfig.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/juick/config/WebConfig.java b/src/main/java/com/juick/config/WebConfig.java index fcd9a46b..59f9a99c 100644 --- a/src/main/java/com/juick/config/WebConfig.java +++ b/src/main/java/com/juick/config/WebConfig.java @@ -45,6 +45,8 @@ import org.springframework.core.io.Resource; import org.springframework.http.CacheControl; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.security.web.firewall.HttpStatusRequestRejectedHandler; +import org.springframework.security.web.firewall.RequestRejectedHandler; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -204,4 +206,8 @@ public class WebConfig implements WebMvcConfigurer { public User archiveUser() { return userService.getUserByName(archiveUsername); } + @Bean + public RequestRejectedHandler requestRejectedHandler() { + return new HttpStatusRequestRejectedHandler(); + } } -- cgit v1.2.3