Template project with
- Spring Boot 2.2.1
- Spring Security (JWT)
- Spring Data
- Lombok
- Flyway
- Swagger
- Docker
- PostgresSQL
Postgres local (profile dev)
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
Postgres in docker network (profile container)
spring.datasource.url=jdbc:postgresql://db:5432/store?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
spring.datasource.username=postgres
spring.datasource.password=postgres
From project directory, start up the application by running.
docker-compose up -d --build
Compose pulls and build the images from project, and starts the services.
http://localhost:8080/store/swagger-ui.html
Enter http://localhost:8080/store/swagger-ui.html in a browser to see the application running.
POST /store/auth/login HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"username": "jhon@gmail.com",
"password": "123456"
}
The security expects a token named authorization with the generated JWT.
GET /store/products HTTP/1.1
Host: localhost:8080
Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIwZGZkNTZjOS03NzU4LTRjYzAtOTg0Zi01ZjFhOTA2ZjcyOGMiLCJpYXQiOjE1Nzk0ODY2ODcsImV4cCI6MTU4MDA5MTQ4N30.Ewn0A0OTSX9Ik8dDmQDe33UklZkUD62L-5F_I11dYkpCWqHlpjyOfy8FNS6pJAp4g2EGrRXRFquxaizvfJRQzw
The project uses two types of roles.
ROLE_ADMIN
ROLE_USER