This is a simple Spring Boot application that demonstrates how to implement user authentication using JSON Web Tokens (JWT) in Spring Boot OAuth2 Resource Server and Spring Security. The application also includes a access token and refresh token functionality.
⭐ If you find this project useful, please consider giving us a star on GitHub! Your support helps us continue to innovate and deliver exciting features.
- User authentication via JWT
- Refresh token functionality
- Clone the repository
- Edit the
application.properties
file to configure the database and JWT information:
# ===============================
# = JWT CONFIGURATION
# ===============================
# Below are the configurations for JWT
# JWT Access Token Expiration Time
jwt.access-token.expiration-time=3600
# JWT Refresh Token Expiration Time
jwt.refresh-token.expiration-time=86400
# ===============================
# = SERVER
# ===============================
# Set here configurations for the web server
server.port=8080
- Navigate to the project directory
- Run the application using the command
./mvnw spring-boot:run
- POST
/api/auth/login
: Authenticate a user and return an access and refresh token.
{
"email": "[email protected]",
"password": "123"
}
{
"access_token": "access_token",
"refresh_token": "refresh_token"
}
- POST
/api/auth/refresh-token
: Refresh the access token.
Authorization: Bearer <refresh_token>
{
"access_token": "access_token",
"refresh_token": "refresh_token"
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.