Package com.bank.auth_service.controller
Class AuthenticationController
java.lang.Object
com.bank.auth_service.controller.AuthenticationController
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<AuthenticationTokenDto> authenticate
(LoginUserDto loginUserDto, jakarta.servlet.http.HttpServletRequest httpServletRequest) Authenticates a user with email and password, generating authentication tokens.org.springframework.http.ResponseEntity
<String> refreshToken
(UUID refreshToken, jakarta.servlet.http.HttpServletRequest httpServletRequest) Refreshes the authentication token using a valid refresh token.
-
Constructor Details
-
AuthenticationController
-
-
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 invalidUserNotFoundException
- 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 loginhttpServletRequest
- the HTTP servlet request containing client metadata- Returns:
- new JWT authentication token as a String
- Throws:
RefreshTokenNotFoundException
- if the refresh token does not existRefreshTokenExpiredException
- if the refresh token has expired
-