Spring Boot backend connected to MySQL database for managing basketball league data
- Language: Java 21
- Framework: Spring Boot 3.5.7
- Build Tool: Maven
- Database: MySQL 8+ (local)
- Security: Spring Security (JDBC-based users/authorities)
- DB Access: Spring JDBC (JdbcTemplate), no JPA
- Java JDK 21
- Maven 3.9+
- MySQL Server 8+ running locally
- An IDE (IntelliJ IDEA, Eclipse, etc.)
- Configure
src/main/resources/application.propertieswith valid details - Create
src/main/resources/secrets.propertiesfile followingsecrets.properties example - To create all required tables, run the SQL DDL script located here:
src/main/resources/db/Schema.sql
POST /auth/register
Register a new user account. New users are automatically assigned the USER role.
Request Body:
{
"username": "string",
"password": "string"
}Success Response (201 Created):
{
"accessToken": "string",
"refreshToken": "string"
}Error Response (409 Conflict):
{
"error": "USERNAME_TAKEN",
"message": "The username 'username' is already in use.",
"username": "string"
}POST /auth/login
Authenticate an existing user and receive JWT tokens.
Request Body:
{
"username": "string",
"password": "string"
}Success Response (200 OK):
{
"accessToken": "string",
"refreshToken": "string"
}Error Response (401 Unauthorized):
{
"error": "INVALID_CREDENTIALS",
"message": "Invalid username or password."
}POST /auth/refresh
Obtain a new access token using a valid refresh token.
Request Body:
{
"refreshToken": "string"
}Success Response (200 OK):
{
"accessToken": "string"
}Error Response (403 Forbidden):
Invalid refresh token
-
Registration/Login:
- Call
/auth/registerto create a new account, or/auth/loginto authenticate - Both endpoints return an
accessTokenandrefreshToken
- Call
-
Using Protected Endpoints:
- Include the
accessTokenin theAuthorizationheader as:Authorization: Bearer <accessToken> - Access tokens are used to authenticate requests to protected endpoints:
/team/**- Requires authentication (any authenticated user)/game/**- Requires authentication (any authenticated user)/player/**- RequiresADMINrole
- Include the
-
Token Refresh:
- When the access token expires, use
/auth/refreshwith yourrefreshTokento obtain a newaccessToken - Refresh tokens have a longer expiration time than access tokens
- When the access token expires, use
-
Token Format:
- Tokens are JWT (JSON Web Tokens) and should be included in the
Authorizationheader - Format:
Authorization: Bearer <token>
- Tokens are JWT (JSON Web Tokens) and should be included in the