P1
Phase 1 Index & Roadmap

Foundations, Entities, Tokens & Integration

RESTRUCTURED CURRICULUM • 3 WEEKS • 21 SESSIONS • ~30 HOURS

Phase 1: Basic — Foundations, Entities, Tokens & Stateless Integration

แผนผังหลักสูตร Phase 1 ฉบับปรับปรุงใหม่ที่จัดเรียงลำดับการเรียนรู้ตามหลัก First Principles & Progressive Mastery: เริ่มต้นจากการทำความเข้าใจความหมายและบทบาทของ "ตัวละครหลักในระบบ IAM" (Keycloak Engine, Realms, Users, Credentials, และ Clients) ไต่ระดับไปสู่ "บัตรผ่านและสิทธิ์การเข้าถึง" (RBAC Roles, Declarative User Profiles, JWT Token Anatomy, Mappers และ Session RTR) และปิดท้ายด้วย "การประกอบระบบเข้ากับ Backend จริง" (Stateless JWKS Signature Verification โดยไม่ต้องพึ่งพา Database ซ้ำซ้อน)

Duration 3 Weeks 21 Modules & Labs
Pedagogical Arc First Principles Entities ➔ Tokens ➔ API
Protocol Guard RFC 7636 / 6749 PKCE S256 & M2M
Verification Model Stateless JWKS Zero DB Query Checks

🏛️ The 3 Progressive Milestones of Phase 1

Logical Learning Progression
01

Week 1: Identity Foundations & Entities

ทำความเข้าใจว่า Keycloak คืออะไร (7 Core Subsystems), ติดตั้ง Decoupled Persistence ด้วย PostgreSQL, เข้าใจความแตกต่างระหว่าง Master Realm กับ Business Tenant, จัดการ Users/Credentials, และจำแนก Public vs Confidential Clients

02

Week 2: Governance, Tokens & Lifecycles

จัดวางโครงสร้างสิทธิ์ RBAC (Realm vs Client Roles, Composite Roles), จัดการ Groups, Declarative User Profiles, ผ่าชิ้นส่วน JWT ป้องกันปัญหา Token Bloat (HTTP 431), ปรับแต่ง Mappers และคุม Session Lifecycle ด้วย Refresh Token Rotation

03

Week 3: Backend Verification & Capstone

เชื่อมต่อโลกจริง: ดึง Public Keys จาก JWKS Endpoint (/certs) มาแคชในหน่วยความจำ, สร้าง Resource Server ตรวจสอบ Bearer Token, บังคับใช้ Scopes/Roles ใน API, จัดการ Single Logout (RFC 7009), และประกอบระบบ End-to-End

WEEK 1 • DAYS 01 - 07

Identity Foundations & Basic Entities

เข้าใจนิยามของ Keycloak, กายวิภาคภายใน 7 Subsystems, การรัน Persistent Database, OIDC/PKCE, และการสร้าง Entities

DAY 01 What is Keycloak?

Anatomy, Quarkus Runtime & First Realm

นิยาม Keycloak ในภาษามนุษย์ (Before vs After IAM), กายวิภาค 7 Core Subsystems, สถาปัตยกรรม Quarkus Runtime, Agroal Connection Pool, PostgreSQL Persistence, และ Master Isolation

Target Artifact: docker-compose.yml with Agroal Pool & Persistent Volume
DAY 02 RFC 7636 / OIDC Core

Demystifying OAuth 2.0 vs OIDC & PKCE

เปรียบเทียบ Authorization vs Authentication, กลไก Front vs Back-channel, การคำนวณ code_verifier และ S256 challenge, State ป้องกัน CSRF, Nonce ป้องกัน Replay

Target Artifact: Terminal Bash/OpenSSL PKCE Generator & Token Exchange CLI
DAY 03 Keycloak Entities

Realms, Users, Credentials & Storage Boundaries

ทำความเข้าใจความหมายของ Realm (Tenant Boundary), โครงสร้างตาราง USER_ENTITY และ USER_ATTRIBUTE, กลไก Password Hashing (PBKDF2/Argon2) และการจัดการ Credentials ผ่าน Admin Console

Target Artifact: Realm Isolation Blueprint & User Provisioning Script
DAY 04 Client Architecture

Clients Anatomy: Public vs Confidential Clients

Client ใน Keycloak คืออะไร, ความแตกต่างระหว่าง Public (SPA/Mobile) vs Confidential (Backend), กฎความปลอดภัย Valid Redirect URIs (ห้ามใช้ Wildcard), Web Origins (CORS), และ Post-logout URIs

Target Artifact: Hardened Client JSON Export with Strict URI Matching
DAY 05 M2M Security

Service-to-Service Security & Client Credentials Grant

การเชื่อมต่อระหว่าง Microservices/Background Daemon (RFC 6749 Sec 4.4), Service Accounts ใน Keycloak, การจำกัดสิทธิ์แบบ Least Privilege, และวงจร Zero-Downtime Secret Rotation

Target Artifact: Automated Background Worker Script & Service Account Config
DAYS 06 - 07 Checkpoint Lab #1

Entity Modeling Audit & CLI Handshake Suite

รวบรวมองค์ประกอบในสัปดาห์ที่ 1: ตรวจสอบความถูกต้องของ Realm, Users, Credentials, Public SPA Client, และ Confidential Client พร้อมสร้าง Bash Automated Test Suite ทดสอบ Handshake

Target Artifact: Comprehensive Handshake Test Script (verify-entities.sh)
Checkpoint Lab Assignment #1
WEEK 2 • DAYS 08 - 14

Roles, Claims & Token Architecture

การจัดสถาปัตยกรรมสิทธิ์ (RBAC), Declarative User Profiles, โครงสร้าง JWT, Protocol Mappers, และ Session Lifecycles

DAY 08 Authorization RBAC

Authorization Basics: Realm Roles vs Client Roles

บทบาทและหน้าที่ของ Role ในระบบ IAM, ขอบเขตความแตกต่างระหว่าง Realm Roles (สิทธิ์กว้าง) vs Client Roles (สิทธิ์เจาะจง Service), และการจัดกลุ่ม Composite Roles มัดรวมสิทธิ์

Target Artifact: Composite Role Hierarchy & Permission Matrix Spec
Curriculum Module Day 08
DAY 09 User Governance

Groups & Declarative User Profile Management

การบริหารจัดการ Groups (การสืบทอดสิทธิ์ลำดับขั้น), การเปิดใช้ Declarative User Profile (UP), กำหนด Validation Rules (Regex, Required), และ Read-Only vs Admin-Only Fields

Target Artifact: Declarative User Profile Schema JSON Specification
Curriculum Module Day 09
DAY 10 Token Deep-Dive

Deep-Dive JWT Anatomy & Token Bloat Defense

ผ่าชิ้นส่วน JSON Web Token (JOSE Header, Payload Claims, Signature), ปัญหาวิกฤต Token Bloat จากการเปิด Full Scope Allowed ที่ทำให้ Ingress เกิด HTTP 431, และหลัก Data Minimization

Target Artifact: Lean JWT Formatter & Ingress Buffer Safety Configuration
Curriculum Module Day 10
DAY 11 Claims Projection

Protocol Mappers, Custom Claims & Scopes Strategy

การทำงานของ Protocol Mappers, การแทรก Audience Claim (aud) ป้องกัน Confused Deputy, การแยกปลายทางของ Claims (Access Token vs ID Token vs /userinfo), และ Type Casting

Target Artifact: Modular Client Scope with Audience & Attribute Mappers
Curriculum Module Day 11
DAY 12 Session Lifecycle

Session Lifecycles & Refresh Token Rotation (RTR)

SSO Session Idle Timeout vs SSO Session Max Lifespan, ปัญหา Zombie Sessions, กลไก Refresh Token Rotation (RTR), และการตรวจจับ Replay Attacks พร้อมคำสั่ง Cascade Revocation

Target Artifact: Hardened Session Policy & Replay Detection Validation Suite
Curriculum Module Day 12
DAYS 13 - 14 Checkpoint Lab #2

Token Security & OWASP BCP Audit Lab

ตรวจสอบโครงสร้าง Tokens, Roles, Scopes และ Lifecycles ทั้งหมดเทียบกับ OWASP OAuth 2.0 Security BCP, จำลอง Replay Attack, และตรวจวัดขนาด Payload ของ Token

Target Artifact: Automated Token Security Audit Report & Remediation Script
Checkpoint Lab Assignment #2
WEEK 3 • DAYS 15 - 21

Backend Integration & Stateless Verification

การตรวจสอบความถูกต้องของ Token ผ่าน JWKS Endpoint, การสร้าง Resource Server API, การทำ Logout, และ Capstone Project

DAY 15 JWKS Architecture

Public Key Cryptography & JWKS Endpoint (/certs)

เบื้องหลังการ Sign Token ของ Keycloak (Asymmetric RSA/EC), โครงสร้าง JSON Web Key Set (JWKS), การจับคู่ Key ID (kid), Active vs Passive Keys, และ Key Rotation

Target Artifact: Independent Public Key Signature Verifier Script (Python/Node)
Curriculum Module Day 15
DAY 16 Resource Server

Building the Resource Server: Stateless Token Verification

การสร้าง Backend API ทำหน้าที่เป็น Resource Server: แคช Public Key ในหน่วยความจำ, ตรวจสอบ Signature, ตรวจสอบ Issuer (iss) และ Expiration (exp), ตอบสนอง 401 Unauthorized

Target Artifact: Production-Grade Bearer Token Verification Middleware
Curriculum Module Day 16
DAY 17 API Authorization

Enforcing Scopes & Role-Based Access Control in API

การเขียนโค้ดสกัด Authorization Context จาก JWT: ตรวจสอบ Client Roles, ตรวจสอบ Scopes (เช่น read:orders), การป้องกัน 403 Forbidden และ Contextual Claims Validation

Target Artifact: Fine-Grained Role & Scope Enforcement API Decorators
Curriculum Module Day 17
DAY 18 Revocation & Logout

Logout Architectures & RFC 7009 Token Revocation

ความท้าทายในการ Logout ของระบบ Stateless JWT, มาตรฐาน RFC 7009 Token Revocation, ความแตกต่างของ Frontchannel vs Backchannel Logout, และการจัดการ Single Sign-Out

Target Artifact: Backchannel Logout Listener Webhook & Revocation Flow
Curriculum Module Day 18
DAY 19 Phase 1 Capstone

Phase 1 Capstone: Unified End-to-End IAM Architecture

ประกอบทุกส่วนเข้าด้วยกัน: Single Page App (PKCE) + Keycloak + PostgreSQL + Stateless Resource Server (ครบวงจร Login ➔ Issue Lean Token ➔ API Check ➔ Scope Enforce ➔ Single Logout)

Target Artifact: Complete 3-Tier Dockerized Architecture with Integration Tests
Phase 1 Capstone Project
DAYS 20 - 21 Exit Gate Exam

Comprehensive 3-Week Assessment & Architecture Defense

การประเมินผลรวบยอดทั้ง 21 วัน ครอบคลุม Entities, Protocols, Token Mechanics, และ Backend Verification พร้อมตรวจสอบความพร้อมก่อนก้าวสู่ Phase 2 (Enterprise Federation & Flows)

Target Artifact: Phase 1 Mastery Certificate & Technical Defense Report
Exit Gate Defense Assessment

📋 Phase 1 Technical Standards & RFC Blueprint

มาตรฐานทางวิศวกรรมสากลที่นำมาใช้เป็นเกณฑ์กำหนดเนื้อหาใน Phase 1

Standards Compliance: 100%
Specification / RFC Title / Subject Phase 1 Realignment Application Core Engineering Rule
RFC 6749 The OAuth 2.0 Authorization Framework Day 2 (Auth Code Flow) & Day 5 (Client Credentials M2M Flow) Deprecate Implicit Flow (Strict POST)
RFC 7636 Proof Key for Code Exchange (PKCE) Day 2 (Public Clients on SPA & Mobile Applications) S256 Mandatory (Base64URL SHA-256)
RFC 7519 JSON Web Token (JWT) Day 10 (JWT Anatomy) & Day 11 (Protocol Mappers & Claims) Lean Payload (< 1KB Target to avoid 431)
RFC 7517 JSON Web Key (JWK / JWKS) Day 15 (Key Sets /certs) & Day 16 (Stateless Token Verification) In-Memory Cache & kid Rotation Matching
RFC 7009 OAuth 2.0 Token Revocation Day 18 (Token Revocation & Single Sign-Out Architecture) Immediate Invalidation of Refresh Tokens
OIDC Core 1.0 OpenID Connect Core Specification Day 2 (ID Token, Nonce/State) & Day 11 (UserInfo Offloading) Strict Identity Assertion Separation
Looking at the Bigger Picture?

Explore the Grand 16-Week Multi-Phase Roadmap

ดูผังรวมระดับองค์กรทั้ง Phase 1 (Basic), Phase 2 (Enterprise Federation), และ Phase 3 (Java SPIs & K8s HA)

Go to Macro Master Index →