Hi after implementing the spring security with jwt token it is working as expected with known API urls but when I hit with unknown URL, get 401 authorized error and if any exception is raised at runtime also gets 401 authorized because fo the below exception in Cansole.
getting org. spring framework.security.authentication.InsufficientAuthenticationException
do I need to add any filter in AuthEntryPointJwt under the commence? I just wanted to ignore the authentication filter if there is any unknown API hit that came to the application and should throw the NoHandlerFoundException custom exception error with below handler. how can I do that?
@ExceptionHandler(NoHandlerFoundException.class)
public ResponseEntity handle(NoHandlerFoundException ex){
return new ResponseEntity<>(APIError.createInstance(HttpStatus.NOT_FOUND.toString(),
List.of(new ErrorDetails(ex.getMessage(),null))), null, HttpStatus.NOT_FOUND);
}
Hi after implementing the spring security with jwt token it is working as expected with known API urls but when I hit with unknown URL, get 401 authorized error and if any exception is raised at runtime also gets 401 authorized because fo the below exception in Cansole. getting org. spring framework.security.authentication.InsufficientAuthenticationException
do I need to add any filter in AuthEntryPointJwt under the commence? I just wanted to ignore the authentication filter if there is any unknown API hit that came to the application and should throw the NoHandlerFoundException custom exception error with below handler. how can I do that?
@ExceptionHandler(NoHandlerFoundException.class) public ResponseEntity handle(NoHandlerFoundException ex){
return new ResponseEntity<>(APIError.createInstance(HttpStatus.NOT_FOUND.toString(),
List.of(new ErrorDetails(ex.getMessage(),null))), null, HttpStatus.NOT_FOUND);
}