System Requirements
Required Software
Java Development Kit
JDK 21 or higherVerify installation:
PostgreSQL
PostgreSQL 12+ recommendedRunning on default port 5432
Maven
Maven 3.6+ (optional)Maven wrapper included in project
Git
Git for version controlClone the repository
Hardware Recommendations
- Memory: Minimum 2GB RAM (4GB recommended)
- Storage: 500MB free disk space
- CPU: Any modern processor
Installation Steps
Install JDK 21
Configure Application
Set up your environment variables. The service uses the following configuration from
application.properties:Set Environment Variables
Configure the required environment variables:
JWT_SECRET: Must be Base64-encoded, minimum 256 bits (32 bytes)
JWT_EXPIRATION_MS: Token lifetime in milliseconds (86400000 = 24 hours)
JWT_EXPIRATION_MS: Token lifetime in milliseconds (86400000 = 24 hours)
Build the Project
Compile the project using Maven:This will create a JAR file in the
target/ directory.Configuration Reference
Database Settings
The service uses Spring Data JPA with PostgreSQL:| Variable | Description | Default | Required |
|---|---|---|---|
DB_NAME | PostgreSQL database name | - | Yes |
DB_USERNAME | Database user | - | Yes |
DB_PASSWORD | Database password | - | Yes |
JWT Configuration
| Variable | Description | Example | Required |
|---|---|---|---|
JWT_SECRET | Secret key for signing tokens (Base64) | See below | Yes |
JWT_EXPIRATION_MS | Token expiration time in milliseconds | 86400000 | Yes |
Hibernate Schema Management
Thespring.jpa.hibernate.ddl-auto property controls database schema handling:
update(Development): Automatically updates schema based on entitiesvalidate(Production): Only validates schema, doesn’t modifynone(Production): No schema management
Project Dependencies
Frompom.xml, the service includes:
Core Dependencies
Key Libraries
- Spring Boot Web MVC 4.0.2: REST API framework
- Spring Security 6: Authentication and authorization
- Spring Data JPA: Database persistence
- JJWT 0.12.6: JWT token generation and validation
- SpringDoc OpenAPI 2.8.9: API documentation (Swagger UI)
- PostgreSQL Driver: Database connectivity
- Lombok: Reduce boilerplate code
- Jakarta Validation: Request validation
- Spring Dotenv 4.0.0: Environment variable management
Database Initialization
Automatic Schema Creation
Withspring.jpa.hibernate.ddl-auto=update, Hibernate will automatically create tables for:
- Users
- Roles
- Permissions
- Modules
- Activity Logs (Audit)
- User-Role mappings
- Role-Permission mappings
Initial Data Setup
You’ll need to create initial users and roles. Here’s a sample SQL script:Password hashes should be generated using BCrypt with strength 10. Use the service’s own user creation endpoint once you have an initial admin user.
API Documentation
Once running, access the interactive API documentation:- Swagger UI:
http://localhost:8080/swagger-ui.html - OpenAPI JSON:
http://localhost:8080/v3/api-docs
Main Endpoints
| Endpoint | Method | Description | Auth Required |
|---|---|---|---|
/api/auth/login | POST | Authenticate and get JWT token | No |
/api/users | GET | List all users | Yes |
/api/users | POST | Create new user | Yes (WRITE_PRIVILEGES) |
/api/users/{id} | GET | Get user by ID | Yes (READ_PRIVILEGES) |
/api/users/{id} | PUT | Update user | Yes (WRITE_PRIVILEGES) |
/api/users/{id}/activate | PATCH | Activate user | Yes (WRITE_PRIVILEGES) |
/api/users/{id}/deactivate | PATCH | Deactivate user | Yes (WRITE_PRIVILEGES) |
/api/users/{id}/roles/{roleId} | POST | Assign role to user | Yes (WRITE_PRIVILEGES) |
/api/users/{id}/roles/{roleId} | DELETE | Revoke role from user | Yes (WRITE_PRIVILEGES) |
/api/users/search | GET | Search users (paginated) | Yes (READ_PRIVILEGES) |
/api/audit-logs | GET | Query audit logs | Yes |
Production Deployment
Build Production JAR
target/autorization-0.0.1-SNAPSHOT.jar
Run as System Service
Production Checklist
Security Configuration
Security Configuration
- Use strong, randomly generated JWT secret
- Configure HTTPS/TLS
- Set up CORS policies
- Use environment-specific database credentials
- Enable rate limiting
- Configure secure session management
Database Configuration
Database Configuration
- Use connection pooling (HikariCP is included)
- Set
spring.jpa.hibernate.ddl-auto=validate - Disable
spring.jpa.show-sql - Configure backup strategy
- Set up read replicas (if needed)
- Enable SSL for database connections
Monitoring & Logging
Monitoring & Logging
- Configure centralized logging
- Set up application monitoring (Prometheus, Grafana)
- Enable Spring Boot Actuator endpoints
- Configure log rotation
- Set appropriate log levels
- Monitor audit logs regularly
Performance
Performance
- Configure JVM heap size:
-Xmx2g -Xms2g - Enable GC logging
- Configure connection pool size
- Set up caching (if needed)
- Load test before deployment
Troubleshooting
Common Issues
Port 8080 Already in Use
Port 8080 Already in Use
Change the port in environment variables:Or add to
application.properties:Database Connection Failed
Database Connection Failed
Verify PostgreSQL is running:Test connection manually:Check firewall rules and PostgreSQL
pg_hba.conf configuration.JWT Token Errors
JWT Token Errors
SignatureException: JWT secret mismatch or corrupted token
ExpiredJwtException: Token has expired, request a new one
MalformedJwtException: Invalid token formatEnsure:
- JWT secret is consistent across restarts
- Secret is properly Base64-encoded
- Token hasn’t expired (check
JWT_EXPIRATION_MS)
Build Failures
Build Failures
Clean Maven cache and rebuild:Verify Java version:Both should show Java 21.
Logging
Application logs are written to:- Console output (during development)
logs/directory (configurable viaapp.logs.dir)
Next Steps
Quick Start
Get your first JWT token in minutes
API Reference
Explore all available endpoints
Architecture
Learn about the hexagonal architecture
Security
Understand authentication and authorization