A full-stack application demonstrating the integration of Keycloak (IAM), Spring Boot, and Angular 19.
This project follows a step-by-step learning approach to implement modern authentication and authorization.
- Level 1: Keycloak Setup (Docker, Realms, Clients, Roles, Users).
- Level 2: Spring Boot Backend Integration (OAuth2 Resource Server).
- Level 3: Angular Frontend Integration (Keycloak-Angular, Standalone Components).
- Level 4: Role-Based Access Control (RBAC) (Method-level security in Spring, UI-level security in Angular).
Keycloak-Auth/
βββ backend/ # Spring Boot Application (Port: 8081)
βββ frontend/ # Angular 19 Application (Port: 4200)
βββ docker-compose.yml # Keycloak & PostgreSQL Setup
βββ README.md # Project Documentation
- IAM: Keycloak 24.0.0
- Database: PostgreSQL (for Keycloak)
- Backend: Spring Boot 3.4.x, Spring Security, Lombok
- Frontend: Angular 19, Keycloak-Angular 19.x, Keycloak-JS
- Containerization: Docker & Docker Compose
Start Keycloak and PostgreSQL using Docker:
docker compose up -d- Admin Console: http://localhost:8080
- Credentials:
admin/admin
Navigate to the backend directory and run:
cd backend
./mvnw spring-boot:run- Base URL: http://localhost:8081/api
Navigate to the frontend directory and run:
cd frontend
npm install
npm start- App URL: http://localhost:4200
- Realm:
my-realm - Client:
my-app-client(Public, Standard Flow) - Roles:
USER,ADMIN - Test User:
testuser/password
- Login as
testuser. - Use the UI buttons to call:
- Public API: Accessible to everyone.
- User API: Requires
USERrole. - Admin API: Requires
ADMINrole (Returns 403 if not assigned).