Skip to content

feat(keycloak): search accounts by email or username - #678

Merged
dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-keycloak-user-search-1241
Oct 7, 2026
Merged

dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-keycloak-user-search-1241

Conversation

@samwel141

Copy link
Copy Markdown

Part of Greenstand/treetracker-admin-client#1241

Problem

Binding a legacy wallet to a keycloak account means the admin has to identify that account. Dadiorchen asked on the issue that we define this before coding, and we settled on search rather than pasting a uuid: a pasted id is unverifiable, and the acceptance criteria already ask the wallet detail page to show the keycloak user's name or email, which needs a lookup either way.

The browser cannot hold admin credentials, so the lookup has to be proxied. This API already authenticates to Keycloak with a service account for the organization apply flow, so no new secret is needed.

Change

GET /api/keycloak-users?search=&limit=   accounts matching email or username
GET /api/keycloak-users/{id}             one account, for the detail page

Both behind requireRole(Role.WALLET_ADMIN), the same role that gates the wallet pages in the admin panel. An empty search returns [] without calling Keycloak. Only id, username, email, firstName and lastName are returned.

Verification

5 new tests in src/controllers/keycloakUser.controller.test.ts. Full suite 79 passing, tsc --noEmit clean, eslint and prettier clean.

Related

Binding a legacy wallet to a keycloak account needs the admin to find
that account. The browser cannot hold admin credentials, so the lookup
goes through the service account this API already authenticates with.

Guarded by wallet-admin, the same role that gates the wallet pages in
the admin panel.
@dadiorchen
dadiorchen merged commit 2addda0 into Greenstand:keycloak Oct 7, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants