Simple Spring authentication Project with JWT and MySQL for learning purpose
Create a mysql database for example with Docker:
docker run -d -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=taskdb --name mysqldb -p 3307:3306 mysql:8.0
This command generates a mysql container with the root password secret
Open the project directory and run following command:
mvn spring-boot:run
This will start the Spring Application
Request:
{
"fullName": "John Doe",
"email": "johndoe@mail.com",
"password": "password"
}
Response:
{
"user": {
"id": "fda77ad1-4575-40c1-9ff4-be9f3a01da8e",
"fullName": "John Doe",
"email": "johndoe@mail.com",
"createdAt": "2025-05-26T22:35:02.652+00:00",
"updatedAt": "2025-05-26T22:35:02.652+00:00",
"enabled": true,
"authorities": [],
"username": "johndoe@mail.com",
"credentialsNonExpired": true,
"accountNonExpired": true,
"accountNonLocked": true
},
"token": "TOKEN",
"expiresIn": 3600000
}
Request:
{
"email": "johndoe@mail.com",
"password": "password"
}
Response:
{
"user": {
"id": "fda77ad1-4575-40c1-9ff4-be9f3a01da8e",
"fullName": "John Doe",
"email": "johndoe@mail.com",
"createdAt": "2025-05-26T22:35:02.652+00:00",
"updatedAt": "2025-05-26T22:35:02.652+00:00",
"enabled": true,
"authorities": [],
"username": "johndoe@mail.com",
"credentialsNonExpired": true,
"accountNonExpired": true,
"accountNonLocked": true
},
"token": "TOKEN",
"expiresIn": 3600000
}
Request: Header with Bearer Authorization Response:
[
{
"id": "fda77ad1-4575-40c1-9ff4-be9f3a01da8e",
"fullName": "John Doe",
"email": "johndoe@mail.com",
"createdAt": "2025-05-26T22:35:02.652+00:00",
"updatedAt": "2025-05-26T22:35:02.652+00:00",
"enabled": true,
"authorities": [],
"username": "johndoe@mail.com",
"credentialsNonExpired": true,
"accountNonExpired": true,
"accountNonLocked": true
}
]
Request: Header with Bearer Authorization Response:
{
"id": "fda77ad1-4575-40c1-9ff4-be9f3a01da8e",
"fullName": "John Doe",
"email": "johndoe@mail.com",
"createdAt": "2025-05-26T22:35:02.652+00:00",
"updatedAt": "2025-05-26T22:35:02.652+00:00",
"enabled": true,
"authorities": [],
"username": "johndoe@mail.com",
"credentialsNonExpired": true,
"accountNonExpired": true,
"accountNonLocked": true
}