Java 25Spring Boot 4.1.1Spring Data JPAH2MapStructMaven
View source on GitHub
Read the full README
What it does
Instructors publish courses, students enroll, and paid course content should only be visible to enrolled students. Users can hold several roles (ROLE_ADMIN, ROLE_INSTRUCTOR, ROLE_STUDENT).
Architecture
Feature packages (internal/appuser, internal/course), each layered as controller → usecase → service → DAO interface → JPA implementation. MapStruct converts between JPA entities and API DTOs. Cross-cutting web configuration and domain exceptions live in config/web and internal/common.
Stack and infrastructure
| Area | Status | Details |
|---|---|---|
| Persistence | SQL | H2 in-memory, JPA/Hibernate, schema and seed data created on start |
| Messaging | Not used | No broker or events |
| Cloud | Not used | Runs locally |
| Docker | Not used | No Dockerfile or compose file; port 8080 |
Run it locally
git clone https://github.com/josesaid/taller-spring-security.git
cd taller-spring-security
./mvnw spring-boot:run
# Then
curl -s http://localhost:8080/course/v1/course
Requires JDK 25. H2 console: http://localhost:8080/h2-console (JDBC URL jdbc:h2:mem:taller, user sa).
Endpoints
| Method | Path | Purpose |
|---|---|---|
| GET | /course/v1/course | Published catalog |
| GET | /course/v1/course/{id} | One published course |
| GET | /course/v1/course/{id}/content | Paid course content |
| GET | /course/v1/course/mine | Enrolled courses |
| POST | /course/v1/course | Create course |
| PUT | /course/v1/course/{id} | Update course |
| POST | /course/v1/course/{id}/enroll | Enroll |
| GET | /user/v1/user/me | Current user profile |
| GET | /user/v1/user | List users |
| PUT | /user/v1/user/{id}/roles | Replace roles |
Roadmap
- JWT authentication and a
SecurityFilterChain - Role-based and ownership-based authorization (
@PreAuthorize) - JSON 401/403 responses
- Secrets moved out of source code
- Security and integration tests