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.