Microservicio de autenticación y autorización para Quick Bite con JWT y Spring Security.
- ✅ Autenticación JWT con tokens stateless
- ✅ Control de acceso basado en roles (RBAC)
- ✅ Rate limiting y circuit breaker
- ✅ API REST con documentación Swagger
- ✅ Docker ready
- Java 21
- Spring Boot 4.0.5
- Spring Security + JWT
- MySQL 8.0
- Resilience4j
- Docker
- CLIENTE - Clientes del restaurante
- COCINA - Personal de cocina
- ADMIN - Administradores
- REPARTIDOR - Repartidores
# 1. Crear base de datos
CREATE DATABASE quickbite_auth;
# 2. Ejecutar aplicación
./mvnw spring-boot:rundocker-compose up -dLa aplicación corre en http://localhost:8081
| Método | Endpoint | Descripción |
|---|---|---|
| POST | /api/v1/auth/register |
Registrar usuario |
| POST | /api/v1/auth/authenticate |
Iniciar sesión |
| POST | /api/v1/auth/refresh |
Refrescar token |
| POST | /api/v1/auth/validate |
Validar token |
# Registrar usuario
curl -X POST http://localhost:8081/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"username": "juanperez",
"email": "juan@quickbite.com",
"password": "password123",
"firstName": "Juan",
"lastName": "Perez",
"role": "CLIENT"
}'
# Autenticar
curl -X POST http://localhost:8081/api/v1/auth/authenticate \
-H "Content-Type: application/json" \
-d '{
"username": "juanperez",
"password": "password123"
}'- Swagger UI:
http://localhost:8081/swagger-ui.html - Health Check:
http://localhost:8081/actuator/health
Variables de entorno principales:
SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/quickbite_auth
JWT_SECRET_KEY=mySecretKeyForQuickBiteAuthenticationService2024
JWT_EXPIRATION=86400000
SERVER_PORT=8081./mvnw testdocker-compose up -dApache License 2.0