Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting org.springframework.security.authentication.InsufficientAuthenticationException error If I pass unknown api url or method #26

Open
ambeathirumalesu opened this issue Sep 30, 2023 · 0 comments

Comments

@ambeathirumalesu
Copy link

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant