(Spring Boot Ticket Management REST API developed to improve and demonstrate Spring Security concepts such as JWT authentication, role-based authorization, owner-based access control, and audit logging with PostgreSQL.)
TicketTrack is a secure, role-based Ticket Management REST API built with Spring Boot.
It demonstrates authentication, authorization, audit logging, and owner-based access control using JWT and PostgreSQL.
- Java 21
- Spring Boot 3
- Spring Security
- JWT (Stateless Authentication)
- Spring Data JPA (Hibernate)
- PostgreSQL
- Maven
TicketTrack uses JWT-based stateless authentication.
- ADMIN
- MANAGER
- USER
| Operation | USER | MANAGER | ADMIN |
|---|---|---|---|
| Create Ticket | ✅ | ✅ | ✅ |
| View Tickets | ✅ | ✅ | ✅ |
| Update Own Ticket | ✅ | ✅ | ✅ |
| Update Any Ticket | ❌ | ✅ | ✅ |
| Delete Own Ticket | ✅ | ✅ | ✅ |
| Delete Any Ticket | ❌ | ✅ | ✅ |
| View Audit Logs | ❌ | ❌ | ✅ |
Layered architecture: Controller → Service → Repository → Database ↓ Audit ↓ Security (JWT + Role + Owner)
ticket→ Ticket managementuser→ User & role managementsecurity→ JWT authentication & authorizationaudit→ Action loggingcommon→ Base entity & shared logic
- JWT Authentication
- Role-based Authorization
- Owner-based Access Control
- Audit Logging (CREATE / UPDATE / DELETE)
- Global Exception Handling
- DTO-based request/response separation
- PostgreSQL integration
- BCrypt password hashing
POST /api/auth/login
Request: json { "username": "user", "password": "userpass" }
Response: { "token": "JWT_TOKEN" }
2️⃣ Use Token Add to request header: Authorization: Bearer <JWT_TOKEN>
🎫 Ticket Endpoints Create Ticket POST /api/tickets Get All Tickets GET /api/tickets Get Ticket by ID GET /api/tickets/{id} Update Ticket PUT /api/tickets/{id} Delete Ticket DELETE /api/tickets/{id} 📋 Audit Endpoint GET /api/audit Accessible only by ADMIN.
🛢 Database PostgreSQL database name: tickets Example configuration (application.yml): spring: datasource: url: jdbc:postgresql://localhost:5432/tickets username: your_username password: your_password
▶ Running the Project Start PostgreSQL Create database Run the application: ./mvnw spring-boot:run