A robust user management and authentication API built with Spring Boot, featuring JWT authentication, user registration, and comprehensive API documentation.
- 🔐 User registration and authentication
- 🛡️ JWT-based authentication
- 👥 User management with pagination
- 💾 Persistence with JPA
- 📚 Swagger UI for API documentation
- 🔒 Secure endpoints with Spring Security
- 📝 Example responses in Swagger UI
- Java [21]
- Spring Boot [3.2.5]
- Spring Security
- JWT
- Swagger
- Gradle
- PostgreSQL
The database is created automatically when running the project for the first time, but you can also run the DB Script before starting.
-
Clone the repository:
git clone https://github.com/anibalventura/user-management-api.git cd user-management-api-
Configure application properties:
Update the
src/main/resources/application.propertiesfile with your database and JWT configurations.# Database Configuration spring.application.name=user-management-api spring.datasource.url=jdbc:postgresql://localhost:5432/usermanagementdb spring.datasource.username=postgres spring.datasource.password=postgres spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=update # JWT Configuration jwt.secret="u8Jz7Fh2J3kL9mN4pQ6rT8vW0xY2zA5B7D1E3G5H7J9K1L3N5P7R9T1V3X5Z7" jwt.expiration=86400000
-
-
Build the project:
./gradlew build
-
Run the application:
./gradlew bootRun
-
Access the Swagger UI:
Open your browser and navigate to
http://localhost:8080/swagger-ui.htmlto view the API documentation and test the endpoints. Also, you can import the Postman Collection.
-
Authentication:
POST /api/auth/register- Register a new userPOST /api/auth/login- Login a user and return a JWT token
-
User Management:
GET /api/users- Get all users with pagination
-
Register a new user:
POST /api/auth/register { "name": "Anibal Ventura", "email": "contact@anibalventura.com", "password": "password123!", "phones": [ { "number": "9724459", "cityCode": "1", "countryCode": "809" } ] }
-
Login a user:
POST /api/auth/login { "email": "contact@anibalventura.com", "password": "password123!" }
- The application uses JWT for securing endpoints.
- The
SecurityConfigclass configures the security settings, allowing public access to authentication and Swagger endpoints, while securing other endpoints.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT LICENSE.
⭐ Star this repository if you found it helpful!

