Summary

AuthenticationEntryPoint commence method Why is it executed twice

Actual Behavior

throw new UsernameNotFoundException , AuthenticationEntryPoint commence method Why is it executed twice

Expected Behavior

  1. throw new UsernameNotFoundException
  2. First AuthenticationEntryPoint commence method output UsernameNotFoundException message
  3. Then AuthenticationEntryPoint commence method output AuthenticationException message

Configuration

Version

spring-boot-starter-security 2.2.2.RELEASE

Sample

public class MyAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException { String msg = Objects.nonNull(e) ? e.getMessage() : "Unauthorized"; response.sendError(HttpServletResponse.SC_UNAUTHORIZED, msg); } }

Comment From: jzheaux

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add more detail if you feel this is a genuine bug.

Comment From: bishwa-poudel

Stucked in the same issue. @h7asoka have you found any fix to this?