Spring Boot API for KuenyaWZ project.
This project is to be implemented for our KuenyaWZ site.
- Entities - Controllers - Services - Repositories:
- Completed: Account, Product, Variant, Product Images, Order, Order Item, Transaction, CustomSchedule
- Authentication/Authorization:
- Completed: JWT Authentication
Should be noted that we'll need to implement integration of methods for the actual website business logic.
Refer to this Swagger Documentation
- Java JDK 21 (This project has not been compiled to JAR yet)
- Maven 3.9.9+
- PostgreSQL 13
- Database: H2 in memory
- Spring Boot Port: 8081 (development) | 62081 (docker)
- Base URL:
http://localhost:8081/api
- Clone this repository
- Change directory to the cloned repository
- Run
mvn spring-boot:run
Make sure the profile requirement is met. For example, to run with postgres profile,
please make sure you have PostgreSQL installed and running with the provided .ENV
.
- Add profile to environment variable:
set SPRING_PROFILES_ACTIVE=postgres
- Run
mvn spring-boot:run
Environment requirements:
key | description |
---|---|
JWT_SECRET | Base 64 secret key |
JWT_ACCESS_EXP_SECONDS | Token availability until expiration (in seconds), default=3600 |
REFRESH_TOKEN_EXP_DAYS | Refresh token availability until expiration (in days), default=7 |
APP_MASTER_KEY | Master key for application, checks X-Api-Key header. Specifically used on exposed resource endpoints e.g. Accounts endpoints |
Authentication process:
POST /api/auth/register
Registration to create new account and retrieve authententication responsePOST /api/auth/login
Login to authenticate to an account and retrieve authententication responseGET /api/auth/me
Me to retrieve current access token's user details/account/ownerPOST /api/auth/refresh
Refresh to get new access token (JWT token)POST /api/auth/revoke
Revoke to invalidate a refresh tokenn (used when logging out)
The refresh token is generated using Java's SecureRandom
and ancoded using Base64.
This app is made to be deployed in a Docker container. We might then expose it using Nginx.
docker build -t kuenyawz-api:latest .
docker-compose up --build
docker-compose down