This service provides functionality for user management, including user authentication, gathering user details and user account management.
Before you begin, ensure you have met the following requirements:
-
Setup the following environment variables:
USER_SERVICE_AWS_ACCESS_KEY_ID=*** USER_SERVICE_AWS_SECRET_ACCESS_KEY=*** USER_SERVICE_AWS_REGION=*** COGNITO_CLIENT_ID=*** COGNITO_USER_POOL_ID=*** COGNITO_HOSTED_UI_BASE_URL=***
To run the application locally, follow these steps:
-
Clone the repository:
git clone https://github.com/SoftwareEngineering-E-Complish/user_service.git cd your-repository -
Build the application:
mvn clean install
-
Run the application:
mvn spring-boot:run
The application will start and be accessible at http://localhost:8080.
To run the application in a Docker container, you'll need Docker installed on your machine. Follow these steps:
-
Build the Docker image:
docker build -t <your-image-name> .
-
Run the Docker container:
# real User Manager (AWS Cognito) docker run -e USER_SERVICE_AWS_REGION=$USER_SERVICE_AWS_REGION -e USER_SERVICE_AWS_ACCESS_KEY_ID=$USER_SERVICE_AWS_ACCESS_KEY_ID -e USER_SERVICE_AWS_SECRET_ACCESS_KEY=$USER_SERVICE_AWS_SECRET_ACCESS_KEY -e COGNITO_CLIENT_ID=$COGNITO_CLIENT_ID -e COGNITO_USER_POOL_ID=$COGNITO_USER_POOL_ID -e COGNITO_HOSTED_UI_BASE_URL=$COGNITO_HOSTED_UI_BASE_URL -p 8080:8080 <your-image-name> # mocked User Manager docker run -p 8080:8080 <your-image-name>
The application will start within the Docker container and be accessible at http://localhost:8080.
The base URL for all endpoints is: http://localhost:8005
- URL:
/loginURL - Method:
GET - Description: Retrieves the login URL for the Hosted UI.
- Response: Returns the login URL as a string.
- Throws:
URISyntaxExceptionif there is an issue with the URI syntax.
- URL:
/signupURL - Method:
GET - Description: Retrieves the signup URL for the Hosted UI.
- Response: Returns the signup URL as a string.
- Throws:
URISyntaxExceptionif there is an issue with the URI syntax.
- URL:
/logoutURL - Method:
GET - Description: Retrieves the logout URL.
- Response: Returns the logout URL as a string.
- Throws:
URISyntaxExceptionif there is an issue with the URI syntax.
- URL:
/session - Method:
GET - Description: Retrieves the user's session.
- Request Parameter:
authorizationCode(String) - Response: Returns user session in the form of
UserSessionResponseDTO(Fields: accessToken, tokenType, idToken, refreshToken, expiresIn). - Throws:
URISyntaxException,IOException,InterruptedException.
- URL:
/updateUser - Method:
POST - Description: Updates user information.
- Request Body:
UpdateUserDTO(Fields: username, email, name, phoneNumber) - Response: Returns
trueif the user is successfully updated; otherwise,false.
- URL:
/changePassword - Method:
POST - Description: Changes user password.
- Request Body:
ChangePasswordDTO(Fields: accessToken, oldPassword, newPassword) - Response: Returns
trueif the password is successfully changed; otherwise,false.
- URL:
/deleteUser - Method:
GET - Description: Deletes a user.
- Request Parameter:
accessToken(String) - Response: Returns
trueif the user is successfully deleted; otherwise,false.
- URL:
/verifyAccessToken - Method:
GET - Description: Verifies the validity of an access token.
- Request Parameter:
accessToken(String) - Response: Returns
trueif the access token is valid; otherwise,false.
- URL:
/refreshAccessToken - Method:
GET - Description: Refreshes the access token and retrieves new user session.
- Request Parameter:
refreshToken(String) - Response: Returns user session in the form of
UserSessionResponseDTO(Fields: accessToken, tokenType, idToken, refreshToken, expiresIn).
- URL:
/user - Method:
GET - Description: Retrieves user details.
- Request Parameter:
accessToken(String) - Response: Returns user details in the form of
UserResponseDTO(Fields: username, email, name, phoneNumber).
- URL:
/userId - Method:
GET - Description: Retrieves the user ID.
- Request Parameter:
accessToken(String) - Response: Returns the user ID as a string.