Class AuthenticationController

java.lang.Object
com.bank.auth_service.controller.AuthenticationController

@RestController @RequestMapping("/auth") public class AuthenticationController extends Object
Controller for handling authentication-related requests. Provides endpoints for user login and token refresh operations.
Since:
1.0.0
Version:
1.0.0, 06/23/2025
Author:
Fernando Cruz Cavina
See Also:
  • Constructor Details

    • AuthenticationController

      public AuthenticationController(AuthenticationService authenticationService)
  • Method Details

    • authenticate

      @PostMapping("/login") public org.springframework.http.ResponseEntity<AuthenticationTokenDto> authenticate(@RequestBody LoginUserDto loginUserDto, jakarta.servlet.http.HttpServletRequest httpServletRequest)
      Authenticates a user with email and password, generating authentication tokens.
      Parameters:
      loginUserDto - the login credentials (email and password)
      httpServletRequest - the HTTP request (used to capture IP and user-agent)
      Returns:
      AuthenticationTokenDto containing the JWT access token and refresh token
      Throws:
      InvalidUserCredentialsException - if the provided credentials are invalid
      UserNotFoundException - if the user does not exist
    • refreshToken

      @PostMapping("/refresh") public org.springframework.http.ResponseEntity<String> refreshToken(@RequestBody UUID refreshToken, jakarta.servlet.http.HttpServletRequest httpServletRequest)
      Refreshes the authentication token using a valid refresh token.
      Parameters:
      refreshToken - the UUID of the refresh token issued at login
      httpServletRequest - the HTTP servlet request containing client metadata
      Returns:
      new JWT authentication token as a String
      Throws:
      RefreshTokenNotFoundException - if the refresh token does not exist
      RefreshTokenExpiredException - if the refresh token has expired