It's very simple. You just need to update JwtAuthenticationFilter class to parse received JSON data.
JwtAuthenticationFilter
Example:
// POJO with your login data public class LoginData { private String username; private String password; /* getters, setters */ }
// JwtAuthenticationFilter.java @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) { var loginData = parseLoginData(request); var authenticationToken = new UsernamePasswordAuthenticationToken(loginData.getUsername(), loginData.getPassword()); return authenticationManager.authenticate(authenticationToken); } private LoginData parseLoginData(HttpServletRequest request) { try { ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(request.getInputStream(), LoginData.class); } catch (IOException exception) { // Return empty "invalid" login data return new LoginData(); } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's very simple. You just need to update
JwtAuthenticationFilter
class to parse received JSON data.Example: