wimdeblauwe / error-handling-spring-boot-starter

Spring Boot starter for configurable REST API error handling
https://wimdeblauwe.github.io/error-handling-spring-boot-starter/
Apache License 2.0
430 stars 52 forks source link

UnauthorizedEntryPoint returns text instead of json #66

Closed xunterr closed 1 year ago

xunterr commented 1 year ago

Hello, I am trying to set up exception handling for spring security. As it says in the documentation, setting up the UnauthorizedEntryPoint:

@Bean
public UnauthorizedEntryPoint unauthorizedEntryPoint(
                                        HttpStatusMapper httpStatusMapper,
                    ErrorCodeMapper errorCodeMapper,
                    ErrorMessageMapper errorMessageMapper,
                    ObjectMapper objectMapper) {
  return new UnauthorizedEntryPoint(httpStatusMapper, errorCodeMapper, errorMessageMapper, objectMapper);
}

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http, UnauthorizedEntryPoint unauthorizedEntryPoint) throws Exception{

  http
            //...
            .exceptionHandling().authenticationEntryPoint(unauthorizedEntryPoint);

  return http.build();
}

But content type is not a json. Response:

response

wimdeblauwe commented 1 year ago

Found the problem. Will be fixed in an upcoming release.

wimdeblauwe commented 1 year ago

https://github.com/wimdeblauwe/error-handling-spring-boot-starter/releases/tag/4.1.2