protected String getKeycloakUsername ( final HttpServletRequest req , HttpServletResponse resp ) { AtomicReference < String > username = new AtomicReference <> ( ) ; Authenticator . authenticate ( authConfiguration , req , subject -> { username . set ( AuthHelpers . getUsername ( subject ) ) ; // Start httpSession req . getSession ( true ) ; } ) ; return username . get ( ) ; }
With Keycloak integration the Authorization header is available in the request to the UserServlet .