feat(auth): sync Keycloak users for authorization
Generic Container CI/CD / test-build-publish (push) Failing after 33s
Server CI/CD v2 / build-test-publish-and-deploy (push) Failing after 34s

This commit is contained in:
2026-11-04 13:35:29 +08:00
parent bd8c619bfb
commit 9a9add1531
11 changed files with 716 additions and 8 deletions
+10 -4
View File
@@ -37,11 +37,17 @@ but still need a project membership for project business APIs.
Every authenticated metadata-user resolution validates the Keycloak access token
and reads `sub`, `preferred_username`, and `email` claims. The
backend finds `users` by `keycloak_id = sub`, rejects inactive or missing users,
then refreshes `username`, `email`, and `last_login_at`.
then refreshes `username`, `email`, and `last_login_at` for active users.
This keeps local display data current without changing the identity binding.
There is no Keycloak webhook requirement; second-level user or permission sync is
out of scope unless explicitly requested later.
System administrators explicitly synchronize the Keycloak user directory from
the system-management page. New identities are stored with role `user` and
`is_active = false`; existing identities keep their TJWater role, active state,
superuser flag, and project memberships. This makes pending accounts visible
without requiring the user to log in and without granting access automatically.
The administrator's Keycloak account must have the `realm-management`
`query-users` and `view-users` client roles. The backend forwards that access
token only to the same token issuer's Keycloak Admin API; no management
credential is exposed to the browser.
## Admin APIs