How yougnoli/api-authentication-authorization-keycloak-data-api-builder-docker works
Project type and purpose
• This is a Dockerized, demo full-stack API solution showcasing secure data access.
• Keycloak is used as an OAuth2/OIDC Identity Provider.
• Data API Builder (DAB) sits in front of a SQL Server database to expose REST endpoints.
• The goal is to demonstrate multiple authentication flows (anonymous, password, client-credentials, authorization code) and RBAC via DAB.
File structure
• Top level:
• .env – environment variables (e.g., DB credentials, Keycloak admin creds)
• dab-config.json – DAB’s data model and authorization rules
• docker-compose.yml – orchestration for all containers
• SQL/create-sql-env.sql – schema + seed for SQL Server
• DAB/ directory:
• Dockerfile – builds the DAB container
• keycloak.crt – Keycloak’s self-signed cert for trust
• keycloak/ directory:
• certs/keycloak.crt & keycloak.key – SSL certificates for Keycloak HTTPS
• Dockerfile – builds Keycloak server image
• Implicit component: SQL Server container defined in docker-compose.
Extract architectural insights from the README
• Services launched via Docker Compose: Keycloak (port 8443), DAB (port 5000), SQL Server.
• Workflow: clients obtain tokens from Keycloak, then call DAB endpoints.
• DAB validates JWTs using Keycloak’s cert, enforces RBAC, and proxies queries to SQL Server.
• Demonstrates HTTPS between services, use of self-signed certificates for dev.
Main components
a. Clients (Postman/browser/app)
b. Keycloak Identity Provider
c. Data API Builder (DAB)
d. SQL Server database
e. Docker network connecting all services
Relationships and data flows
1. Clients → Keycloak: OAuth2/OIDC token requests (anonymous, password, client-credentials, auth-code flows)
2. Keycloak → Clients: JWT or access tokens over HTTPS
3. Clients → DAB endpoints: attach JWT in Authorization header
4. DAB → Keycloak: fetch/verify JWKS or cert to validate JWT signature
5. DAB → SQL Server: execute SELECT/INSERT/UPDATE based on dab-config.json, enforce row-level and role-level security
6. SQL Server → DAB → Clients: return JSON payloads
Architectural patterns and design principles
• Clear service separation (Auth vs Data).
• Principle of least privilege: DAB applies RBAC rules defined in dab-config.json.
• Deployment as containers: immutable infrastructure via Dockerfiles + compose.
• Certificate trust chain: self-signed cert distribution into DAB.
Technologies and frameworks
• Keycloak (Java, WildFly) for OAuth2/OIDC
• Data API Builder (.NET Core / Azure Data API Builder)
• SQL Server (docker image)
• Docker Compose networking
• OpenSSL for cert generation
• JSON-based DAB configuration for data model & auth rules
3. Ports, protocols (HTTPS, TCP), and security cert exchange.