feat(auth): sync Keycloak users for authorization
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user