From 1bfc1c73c657ccf3dc9ee34354be2053f92c0725 Mon Sep 17 00:00:00 2001 From: ngqile Date: Thu, 26 Nov 2026 19:44:11 +0800 Subject: [PATCH] docs: record admin guard details found while building task 3.1 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM --- openspec/changes/add-admin-auth-users-roles/design.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openspec/changes/add-admin-auth-users-roles/design.md b/openspec/changes/add-admin-auth-users-roles/design.md index 6b686b5..f830fe7 100644 --- a/openspec/changes/add-admin-auth-users-roles/design.md +++ b/openspec/changes/add-admin-auth-users-roles/design.md @@ -29,7 +29,7 @@ Alternative: write admin controllers fresh against Tastefully's backoffice contr ### 2. Admin token check uses `findUserByToken/BO` -On an `/api/admin/**` path the aspect loads the user with `/auth/findUserByToken/BO/{token}`. No user, or a non-admin user, means 403 for a valid member token and 401 for a revoked token. The same lookup gives the roles for the module check and the enabled and login-status flags for the session guard (deactivated means 401; pending password change allows only first-login and logout, otherwise 403). This is one downstream call per admin request. +On an `/api/admin/**` path the aspect first reads the token's `USERTYPE` claim: anything but `A` is a 403. It then loads the user with `/auth/findUserByToken/BO/{token}`; no user (unknown or logged out) is a 401. `findUserByToken` did not check the logout list, so this change makes it return no user for a logged-out token, and adds `BO` to the `Area` enums in core-libs and services-system. `findUserByToken` also adds `ROLE_ADMIN` (id 2) to every admin, so the module check ignores role 2. The pending-reset 403 carries `code: PASSWORD_RESET_REQUIRED`, which the portal uses to redirect. The same lookup gives the roles for the module check and the enabled and login-status flags for the session guard (deactivated means 401; pending password change allows only first-login and logout, otherwise 403). This is one downstream call per admin request. `ponytail:` no cache on this lookup; add a short-TTL cache keyed by token if admin latency matters.