Skip to content

Danh tính & Phân quyền ​

Trang sinh tự động

Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.

Làm gì ​

Tài khoản, phiên, mật khẩu và MFA đều của PIDEAL (không dùng Supabase Auth). Một khách hàng có một tài khoản CUSTOMER với membership theo từng app; nhân viên Web Admin là tài khoản STAFF riêng. Phân quyền theo vai trò với phạm vi, đổi vai trò luôn qua maker/checker.

Quy mô ​

Domain APIidentity, mfa, profile
Query / Mutation12 / 16
Nguồn dữ liệuidentity
Bảng49
Luật phân quyền9
Đường dẫn Web Admin12

Thao tác (mutation) ​

MutationDomainMô tả
approveMembershipidentityPENDING -> ACTIVE for a WEB_ADMIN membership; grants no role (the person
approveMfaResetmfaA different person approves and executes it: factor removed, grants revoked, sessions ended (AD-04, MFA).
approveRoleChangeidentityChecker approves and applies someone else's change (AD-02, MFA); never its maker (same person), super_admin only by a super_admin.
assignRoleidentityFiles a WEB_ADMIN role grant for another staff member (AD-01 maker, MFA).
createRoleidentityNew custom WEB_ADMIN role with no grant (RB-03, MFA step-up).
createStaffAccountidentityCreates a STAFF account, its WEB_ADMIN membership ACTIVE (it can sign in;
deleteAddressprofileRequires profile.manage. Soft-deletes one non-default address.
rejectMembershipidentityRejects a new staff member (PPI-P7-01): every PENDING role request of the
requestMfaResetmfaOpens an MFA reset case for another staff member (AD-03 maker, MFA step-up).
revokeRoleidentityFiles a role revocation for another staff member (AD-01 maker, MFA).
saveAddressprofileRequires profile.manage. Adds or replaces one of the caller's addresses. PAF: at most 10 addresses; a new 11th is refused with extensions.reason address_book_full (editing an existing one still works).
setAccountStatusidentityAccount-wide status with a reason. No matrix rule yet: denied.
setMembershipStatusidentityLock/unlock WEB_ADMIN access with a reason. No matrix rule yet: denied.
setRolePermissionsidentityFiles a grant-set change of a custom role (AD-01 maker, MFA); applied on approval.
updateMeprofileRequires profile.manage. Saves the caller's own profile. A Sale (or any
updateRoleidentityRename/describe a custom role; new version (RB-03, MFA step-up).

Phép đọc (query) ​

QueryDomainMô tả
addressProvincesprofileRequires profile.manage. The Province / City catalogue (34 units) for the
meidentityThe caller. Works while PENDING (that is what the waiting screen reads).
myAddressesprofileRequires profile.manage. The caller's live addresses, default first.
pendingAccountsidentityApproval queue: PENDING WEB_ADMIN registrations, oldest first. Requires staff.read (AD-05).
permissionsidentityPermission catalog grouped by resource. RB-01/RB-02.
roleidentityOne role by app (default WEB_ADMIN) and code. RB-01/RB-02.
roleChangeRequestsidentityMaker/checker queue, oldest first. RB-01/RB-02.
roleHistoryidentityEvery recorded version of a role, oldest first. RB-01/RB-02.
rolesidentityRole catalog with live grants. Requires role_permission.manage/approve (RB-01/RB-02).
staffidentityWEB_ADMIN staff, masked. Requires staff.read (AD-05).
staffAccountsidentitySTAFF accounts with their credential and pending role request, masked,
staffDetailidentityOne staff member, masked. Requires staff.read (AD-05).

Dữ liệu ​

Bảng được tham chiếu nhiều nhất trong module:

BảngCộtĐược trỏ tớiRLS
accounts12240✓
media2315✓
app_memberships1012✓
roles94✓
privacy_requests173✓
role_assignments143✓
sale_applications133✓
sale_teams123✓
mfa_factors172✓
retention_policies102✓

Quyền ​

MãQuyềnỨng dụngVai tròPhạm viTrạng thái
A-01auth.registerAPP_USER, APP_SALEanonymousPUBLICDEFINED
A-02auth.sign_inAPP_USER, APP_SALE, WEB_ADMINanonymousPUBLICDEFINED
A-03auth.password_resetAPP_USER, APP_SALEanonymousPUBLICDEFINED
AD-05staff.readWEB_ADMINadmin super_adminALLPROPOSED
AD-09staff.createWEB_ADMINadmin super_adminALLPROPOSED
AD-10staff.credential_issueWEB_ADMINadmin super_adminALLPROPOSED
RB-01role_permission.manageWEB_ADMINadminALLPROPOSED
RB-02role_permission.approveWEB_ADMINsuper_adminALLPROPOSED
RB-03role_permission.manageWEB_ADMINadminALLPROPOSED

Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.

Giao diện Web Admin ​

Đường dẫnHằng số
/mfa/enrollMFA_ENROLL
/mfa/recoveryMFA_RECOVERY
/permissionsPERMISSIONS
/profilePROFILE
/profile/mfaMFA_STATUS
/profile/mfa/resetsMFA_RESETS
/profile/passwordPROFILE_PASSWORD
/profile/securityPROFILE_SECURITY
/rolesROLES
/roles/:codeROLE_DETAIL
/roles/:code/editROLE_EDIT
/roles/newROLE_NEW

File nguồn ​

Backend:

  • code/apps/api/supabase/functions/graphql/domains/identity/
  • code/apps/api/supabase/functions/graphql/domains/mfa/
  • code/apps/api/supabase/functions/graphql/domains/profile/

Dữ liệu: bảng thuộc domain identity — xem Cơ sở dữ liệu.

Tài nguyên quyền không có luật nào

Bản đồ module khai các tài nguyên account, permission, mfa nhưng ma trận quyền không có luật nào cho chúng. Hoặc tên tài nguyên trong bản đồ sai, hoặc quyền chưa được định nghĩa.

Sinh từ ad83b0aea · 820 migration · PostgreSQL 17