- Clone the project
git clone https://github.com/raphael-97/Quarkus-jwt.git
- Run in the root of this project
mvnw compile quarkus:dev
or
docker compose up
Roles: admin, user
POST /api/auth/login
# Basic Authentication -> You get jwt cookie after successful login
POST /api/auth/register
# All
Jwt token expires in 60 minutes if not changed in application.properties
GET /api/users
# admin, user
GET /api/users/{id}
# admin, user
POST /api/users
# admin
PUT /api/users/{id}
# admin
DELETE /api/users/{id}
# admin
curl -i -X 'POST' 'http://localhost:8080/api/auth/register' -H 'Content-Type: application/json' -d '{ "username": "john", "password": "secret"}'
"am9objpzZWNyZXQ=" is Base64 encoded String of username:password
curl -i -X POST 'http://localhost:8080/api/auth/login' -H 'Authorization: Basic am9objpzZWNyZXQ='
You get a bearer jwt token back
curl -i -X GET 'http://localhost:8080/api/users' -H 'Authorization: Bearer TOKENHERE'
Keep in mind your registered user only has access to endpoints with the user role
One pre-made admin account has the username: "admin" and password: "password"
The Base64 encoded string is: YWRtaW46cGFzc3dvcmQ=
curl -i -X POST 'http://localhost:8080/api/auth/login' -H 'Authorization: Basic YWRtaW46cGFzc3dvcmQ='
curl -i -X POST 'http://localhost:8080/api/users' -H 'Content-Type: application/json' -H 'Authorization: Bearer TOKENHERE' -d '{ "username": "Doe", "password": "secret", "roles": ["admin", "user"]}'