Authorization (การให้สิทธิ์) คืออะไร?
Authorization (AuthZ) คือกระบวนการตัดสินใจว่า "Identity นี้ (User/Service/Device) สามารถทำอะไรได้บ้าง" หลังจากผ่าน Authentication (AuthN) แล้ว เป็นส่วนหนึ่งของ AAA (Authentication, Authorization, Accounting)
🔐 Authorization vs Authentication
| ด้าน | Authentication (AuthN) | Authorization (AuthZ) |
| คำถาม | คุณคือใคร? | คุณทำอะไรได้บ้าง? |
| ตัวอย่าง | Password, MFA, Certificate, Biometric | RBAC Role, ACL, Policy, Scope, Permission |
| ลำดับ | First | Second (หลัง AuthN สำเร็จ) |
🎭 ประเภท Access Control Models (Authorization Models)
| Model | คำอธิบาย | ใช้เมื่อไหร่ | ตัวอย่าง |
| DAC (Discretionary Access Control) | เจ้าของทรัพยากรตัดสินใจสิทธิ์ (ACL per object) | File System, Shared Folder | NTFS ACL, Linux rwx, Google Drive Share |
| MAC (Mandatory Access Control) | ระบบบังคับตาม Label/Policy (Central Policy) | Military, Government, High Security | SELinux, AppArmor, TrustedBSD |
| RBAC (Role-Based Access Control) | สิทธิ์ผูกกับ Role → User/Group ได้ Role | Enterprise, Cloud (Azure RBAC, AWS IAM, K8s RBAC) | Admin, Reader, Contributor, Custom Role |
| ABAC (Attribute-Based Access Control) | Policy ประเมิน Attributes (User, Resource, Environment) | Fine-grained, Dynamic, Zero Trust | AWS IAM Conditions, Azure ABAC, XACML, OPA/Rego |
| PBAC (Policy-Based Access Control) | Policy as Code (Central Policy Engine) | Modern, Cloud-native, Microservices | OPA/Gatekeeper, AWS Cedar, Google Zanzibar |
| ReBAC (Relationship-Based Access Control) | สิทธิ์จาก Relationship (User ↔ Resource) | Social, Collaborative, File Sharing | Google Zanzibar, SpiceDB, OpenFGA |
🌐 Network Authorization (Network Layer)
- NAC (Network Access Control): Pre-admission (Health Check, 802.1X) + Post-admission (VLAN Assignment, ACL)
- Firewall Rules: Source IP/Port, Dest IP/Port, App-ID, User-ID (Palo Alto, FortiGate)
- Zero Trust Network Access (ZTNA): Verify Every Request (Identity + Device + Context) → Policy Decision Point (PDP) → Policy Enforcement Point (PEP)
- SDN/Service Mesh Authorization: K8s NetworkPolicy, Istio AuthorizationPolicy, Cilium NetworkPolicy (L3/L4/L7)
📋 Authorization ใน Cloud (Azure/AWS/GCP)
| Platform | Authorization System | Key Concepts |
| Azure | Azure RBAC | Role Definition (Permissions), Role Assignment (Principal + Scope), Scope (MG, Sub, RG, Resource), Built-in/Custom Roles, Deny Assignments |
| AWS | IAM Policies | Identity-based (User/Group/Role), Resource-based, Permissions Boundaries, SCPs (Organizations), Conditions (Context) |
| GCP | IAM | Roles (Primitive, Predefined, Custom), Principals, Conditions, Policy Binding, Org Policies, VPC Service Controls |
🛠️ Best Practices
- Least Privilege: ให้สิทธิ์น้อยที่สุดที่ทำงานได้
- Separation of Duties: แยก Role ที่ขัดแย้ง (เช่น Deploy vs Approve)
- Just-in-Time (JIT) Access: ให้สิทธิ์ช่วงเวลาจำกัด (Azure PIM, AWS IAM Access Analyzer)
- Policy as Code: GitOps (OPA, Kyverno, Terraform Sentinel)
- Regular Access Reviews: Quarterly Certification Campaign
- Audit Logging: Log ทุก Authorization Decision (Allow/Deny)
⚠️ Common Pitfalls
- Over-permissive Roles (Owner/Contributor ทุกที่)
- Hard-coded Credentials ใน Code/CI/CD
- ไม่มี Expiration สำหรับ Access
- Shared Accounts (Break Accountability)
- ไม่แยก Environment (Dev/Staging/Prod) ด้วย Scope/Subscription
สรุป
Authorization = ตัดสินใจสิทธิ์หลัง AuthN โมเดลหลัก: DAC, MAC, RBAC, ABAC, PBAC, ReBAC Network Layer: NAC, Firewall User-ID, ZTNA, Service Mesh Cloud: Azure RBAC, AWS IAM, GCP IAM หลักการ: Least Privilege, Separation of Duties, JIT, Policy as Code, Audit