Identity Platform (PIP)
Base URL: https://pip.pcampus.co
Overview
Identity Platform (PIP) เป็น core service ที่ทุก service ใน Pcampus ecosystem พึ่งพา ทำหน้าที่เป็น single source of truth สำหรับ identity, access, และ application credentials
PIP แก้ปัญหา 3 ข้อหลักให้ developer:
- ไม่ต้องสร้างระบบ auth เอง
- ไม่ต้องจัดการ permission logic กระจายอยู่หลาย service
- ไม่ต้องสร้าง OAuth server เอง
Who uses this
| Persona | ใช้ทำอะไร |
|---|---|
| Developer (ลูกค้า) | ใช้ OAuth2/OIDC สำหรับ user login, ใช้ API Keys สำหรับ M2M |
| Org Admin | จัดการ members, roles, และ permissions ใน Console |
| End user | Sign up, login, แก้ไข profile ของตัวเอง |
| Internal service | เรียก /access/check ก่อน authorize ทุก request |
Key features
- Authentication — Sign up, login, password reset via ORY Kratos
- OAuth2 / OIDC — Authorization code, client credentials flow via ORY Hydra
- User profiles — Name, contacts (phone, LINE, email), addresses (home, work, billing)
- Organizations — Multi-tenant; users belong to 1+ orgs with different roles
- Role-based access control (RBAC) — Permission catalog
{namespace}.{resource}.{action}, roles, assignments - Application registry — Register OAuth clients, issue M2M API keys
- Audit log — Who did what, when, from where
User stories
Developer integrating PIP:
"ผมต้องการให้ user ของ app ผม login ด้วย Pcampus account ได้ โดยไม่ต้องสร้างระบบ auth เอง" → Register application → ได้ OAuth client → implement authorization code flow
Org admin:
"ผมอยากให้ทีม marketing เข้าถึง Content OS ได้ แต่ไม่ให้แก้ไข user accounts" → สร้าง role
content-editorกับ permissionscontent-os.access,content-os.calendar.write→ assign ให้ member
End user:
"ผมอยากเพิ่มเบอร์โทรและที่อยู่สำหรับการรับ invoice" → ไปที่ Console → Profile → เพิ่ม contact + address
How it works
Data model
Integration with other services
ทุก service เรียก POST /access/check ก่อน authorize request ทุกครั้ง
API overview
| Method | Endpoint | Description |
|---|---|---|
GET | /identity/me | Current user profile |
PATCH | /identity/me | Update profile |
GET | /organizations | List user's orgs |
POST | /organizations | Create org |
POST | /access/check | Check permission |
POST | /access/roles | Create role |
POST | /access/assignments | Assign role |
POST | /applications | Register application |
POST | /applications/:id/api-keys | Create API key |
POST | /oauth2/token | Get OAuth token |