AuthService is a microservice responsible for handling user authentication and authorization in the Expense Tracker application. It manages user registration, login, JWT token generation, and validation. Based on Lovepreet Singh's YT Playlist.
- User registration and login
- JWT token generation
- Token validation
- Password hashing
- Spring Boot
- PostgreSQL
- JWT
- Docker
- Kafka
- JDK 11 or higher (Used JDK 17)
- Docker (optional, for containerization)
- PostgreSQL
- Kafka (optional, for delegating the UserInfo to UserService)
-
Clone the repository:
git clone https://github.com/harsh-1806/auth-service.git cd auth-service
-
Set up PostgreSQL:
- Ensure PostgreSQL is running.
- Create a database for the service.
-
Configure environment variables:
- Add the necessary configuration variables (see Configuration section).
-
Build and run the application:
./mvnw clean install ./mvnw spring-boot:run
(With Default Values)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=root
POSTGRES_PASSWORD='password'
POSTGRES_DB=auth_db
KAFKA_HOST=localhost
KAFKA_PORT=9092
AUTH_SERVICE_PORT=9898
-
Clone the repository:
git clone https://github.com/harsh-1806/auth-service.git cd auth-service
-
Set up PostgreSQL:
- Ensure PostgreSQL is running.
- Create a database for the service.
-
Configure environment variables:
- Add the necessary configuration variables (see Configuration section).
(With Default Values)
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=root
POSTGRES_PASSWORD='password'
POSTGRES_DB=auth_db
KAFKA_HOST=localhost
KAFKA_PORT=9092
AUTH_SERVICE_PORT=9898
After starting the service, you can use the following endpoints to register and authenticate users.
- Endpoint :
api/v1/#
- Method :
POST
- Request Body :
{
"username": "username51",
"password": "123345678",
"first_name": "yourFirstName",
"last_name": "yourLastName",
"phone_number": "1234567890",
"email": "harsh@google.com"
}
- Response Body :
{
"accessToken": "yourAccessToken",
"token": "yourTokenId",
"userId": "userId"
}
- Endpoint :
api/v1/#
- Method :
POST
- Request Body :
{
"username": "username51",
"password": "123345678"
}
- Response Body :
{
"accessToken": "yourAccessToken",
"token": "yourTokenId",
"userId": "userId"
}
- Write some Tests
- Update End-Point for Profile Pic
- Standardized DTOs
- Implement Authorization
- API Documentation