Built with Spring Boot, with a focus on practicing stateless authentication using JWT. It exposes three main endpoints for registration, login and verification of login attempts.
-
Java 21
-
Spring Boot 3
-
Spring Security 6
-
JWT (JSON Web Token)
-
H2 Database (Database in memory)
-
Maven
git clone https://github.com/seu-usuario/spring-auth.git
cd spring-auth
./mvnw spring-boot:run
The application will be available in http://localhost:8082.
Register a new user..
{
"name": "your_name",
"email": "user@example.com",
"password": "your_password"
}
Authenticates a user and returns a JWT token.
{
"email": "user@example.com",
"password": "your_password"
}
{
"email": "user@example.com",
"token": "eyJhbGciOiJIUzI1NiJ9..."
}
Returns the login attempts of the authenticated user.
Authorization: Bearer {token_returned_at_login}
[
{
"id": 1,
"email": "user@example.com",
"status": true,
"createdAt": "2025-04-30T18:00:00"
},
{
"id": 2,
"email": "user@example.com",
"status": false,
"createdAt": "2025-04-30T18:00:00"
}
]
-
Make a POST request to
/api/auth/signupwith the user's JSON body. -
Log in to
/api/auth/loginto get the JWT token. -
Copy the returned token and insert it as the value of the
Authorizationheader withBearerprefix when GETting to/api/auth/loginAttempts.
-
Authentication is completely stateless, there is no session maintained by the server.
-
Login attempts are stored in the H2 database and associated with the user's email.
Matheus de Sousa Almeida
