Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MarcoAbundio/furniture_api_rest/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Furniture API implements security measures including CORS configuration, SSL requirements for database connections, and service registry authentication through Netflix Eureka. This document covers the current security implementation and best practices.CORS Configuration
Cross-Origin Resource Sharing
The API implements CORS to control which frontend applications can access the API endpoints. Configuration:CorsConfig.java
CORS Policy Details
Allowed Paths:/api/** (all API endpoints)
Allowed Origins: https://tu-frontend.com
Allowed Methods:
- GET - Read operations
- POST - Create operations
- PUT - Full update operations
- DELETE - Delete operations
- PATCH - Partial update operations
- OPTIONS - Preflight requests
*)
Credentials: Not enabled by default
Preflight Requests
Browsers automatically send OPTIONS requests before actual requests when:- Using methods other than GET, HEAD, or POST
- Including custom headers
- Using Content-Type other than application/x-www-form-urlencoded, multipart/form-data, or text/plain
Production Considerations
The configuration includes a comment in Spanish: “evitar '' en producción” (avoid '' in production), indicating the current setup should be hardened before deployment.
- Multiple Origins: Support multiple frontend domains
- Specific Headers: Limit allowed headers
- Enable Credentials: If using cookies or authentication
Database Security
SSL/TLS Encryption
The PostgreSQL database connection requires SSL encryption:sslmode=require- Forces encrypted connectionschannelBinding=require- Prevents man-in-the-middle attacks- Connection pooling through Neon pooler
All data in transit between the application and database is encrypted using TLS. Neon uses certificate-based authentication for added security.
Database Credentials
Recommended approach:- Environment Variables: Store credentials externally
-
Secret Management: Use services like:
- AWS Secrets Manager
- HashiCorp Vault
- Kubernetes Secrets
- Spring Cloud Config Server
- Profile-Specific Configuration: Separate configs for dev/prod
Service Discovery Security
Eureka Client Configuration
The microservice registers with Netflix Eureka for service discovery:- Eureka server uses HTTPS protocol
- Service registration is automatic on startup
- IP address is preferred for service-to-service communication
The
@EnableDiscoveryClient annotation in FurnitureApplication.java enables automatic service registration with Eureka, allowing other microservices to discover this API.API Security (Not Yet Implemented)
Recommended Security Additions
For production deployment, consider implementing:1. Spring Security
Add Spring Security dependency:2. JWT Authentication
Implement token-based authentication:3. OAuth 2.0 / OpenID Connect
Integrate with identity providers:- Auth0
- Okta
- Keycloak
- AWS Cognito
4. API Key Authentication
For service-to-service communication:Actuator Security
Spring Boot Actuator endpoints are currently enabled without security:Input Validation
The application includes Hibernate Validator for bean validation:Validation prevents SQL injection and data integrity issues by rejecting invalid input before it reaches the database layer.
Security Headers
Implement security headers to protect against common web vulnerabilities:Best Practices
Development Environment
- Use separate database credentials for development
- Enable detailed error messages for debugging
- Use HTTP for local development
- Keep Swagger UI enabled for API testing
Production Environment
- Never commit credentials to source control
- Use environment variables or secret managers
- Enable HTTPS only (disable HTTP)
- Implement rate limiting
- Add request logging and monitoring
- Disable detailed error messages
- Restrict CORS to specific domains
- Secure all actuator endpoints
- Implement authentication and authorization
- Use API versioning
- Add request/response encryption for sensitive data
Consider using Spring Profiles (
@Profile("prod")) to automatically apply production security configurations when the production profile is active.Future Security Enhancements
Recommended roadmap for security improvements:- Phase 1: Implement JWT authentication
- Phase 2: Add role-based access control (RBAC)
- Phase 3: Implement rate limiting and DDoS protection
- Phase 4: Add API audit logging
- Phase 5: Implement field-level encryption for sensitive data
- Phase 6: Add IP whitelisting for admin endpoints
- Phase 7: Implement API versioning with security policies per version