VNTEZ VNTEZ Docs
Docs / VNTEZ IAM / Phân quyền RBAC
POST /api/iam/evaluate

Ma trận Phân quyền & RBAC Evaluator

Kiểm tra thẩm quyền truy cập thời gian thực trên Cloudflare Worker theo ma trận Resources & Actions.

Cấu trúc Ma trận Quyền (Resource-Action Model)

Hệ thống phân quyền VNTEZ IAM mô hình hóa thẩm quyền dựa trên mô hình phân tầng Root vs Per-App:

  • Root / System Roles (app_id IS NULL): admin (Super Admin *:*), developer, operator, viewer.
  • Per-App Roles (app_id = '<appId>'): Các vai trò định danh theo từng ứng dụng vệ tinh (VD: solotype:admin, gitvn:member) lưu trong bảng Postgres public.iam_roles.

7 Module Tài nguyên Thực tế (Core System Resources):

  1. apps: Quản lý ứng dụng & chứng thực OAuth 2.0 (Client ID, Secret, Redirect URIs).
  2. users: Tài khoản người dùng, định danh SSO và gán vai trò RBAC (iam_user_roles).
  3. database: Quản trị cơ sở dữ liệu Postgres, DDL schema và trình thực thi SQL runner.
  4. blog: Quản trị bài viết kỹ thuật và bình luận.
  5. storage: Quản lý lưu trữ đám mây Cloudflare R2 bucket.
  6. telebot: Telegram Bot Webhook và danh sách người đăng ký nhận thông báo.
  7. settings: Cài đặt bảo mật và biến môi trường toàn cục.

Các hành động chuẩn (Actions):

  • create, read:self, read:all, update:self, update:all, delete:self, delete:all.
  • Wildcard toàn quyền: *:*.

Mẫu gọi API Kiểm tra Quyền

Evaluate RBAC Permission
1
2
3
curl -X POST https://iam.hnamhocit.workers.dev/api/iam/evaluate \
  -H "Content-Type: application/json" \
  -d '{"userId":"usr_sample","resource":"users","action":"read:all"}'

Phản hồi Thành công (200 OK)

{
  "ok": true,
  "allowed": true,
  "userId": "usr_sample",
  "resource": "users",
  "action": "read:all",
  "reason": "Được phép truy cập"
}