@RequestMapping(value = "/authenticate", method = RequestMethod.POST) public ResponseEntity<AuthTokenDTO> authenticate(@Valid @RequestBody AuthenticationDTO authenticationDTO) { User user = userManagementService.authenticateUser( authenticationDTO.getEmail(), authenticationDTO.getPassword()); if (user != null) { return new ResponseEntity<>(buildAuthenticationTokenFromUser(user), HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); } }
https://github.com/vdubois/spring-cloud-sample-authentication-service/blob/a442f7a10bf9529dbb68b669ed394fed51fcc330/src/main/java/io/github/vdubois/controller/AuthenticationController.java