Skip to content

feat(admin): list every wallet for a wallet-admin - #594

Merged
dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-admin-wallet-list-1239
Oct 1, 2026
Merged

dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-admin-wallet-list-1239

Conversation

@samwel141

Copy link
Copy Markdown
Collaborator

Refs Greenstand/treetracker-admin-client#1239

Problem

The admin panel needs a directory of all wallets and nothing serves one.
GET /wallets always starts from the caller's wallet id, so scope=all means
"mine plus the ones I manage". An admin account owns no wallet, so it fails in
the auth middleware before reaching the handler.

Change

GET /admin/wallets: unscoped listing, same limit, offset, name,
sort_by, order conventions, returning { total, query, wallets }.

Authorization is the keycloak wallet-admin role rather than wallet ownership,
so it needs its own middleware. JWTService now returns the token's roles with
its subject, reading both the realm and per-client claims since either can carry
the role.

Verification

  • Unit 238, integration 107, repository 32, eslint clean.
  • Integration covers: lists wallets the caller neither owns nor manages, name
    filter, pagination with an unpaginated total, 403 without the role, 401 with
    no token.
  • Exercised end to end against a local Keycloak with a real wallet-admin
    token, driven from the admin panel.
  • The shared test JWT mock threw a TypeError on a missing Authorization
    header instead of the real 401. Fixed, which is what makes the last case
    testable.

The admin panel needs a directory of all wallets, and nothing served one.
GET /wallets always starts from the caller's wallet id, so scope=all means
"mine plus the ones I manage", and an admin account owns no wallet at all,
so it never even reaches the handler.

Adds GET /admin/wallets: an unscoped listing with the same limit, offset,
name, sort_by and order conventions, returning { total, query, wallets }.

Authorization is the keycloak wallet-admin role rather than wallet
ownership, which is why it needs its own middleware. JWTService now
returns the token's roles alongside its subject, reading both the realm
and per-client claims since either may carry the role.

No token counts on the rows: the list spans the whole table, and counting
per row would be one query per wallet.

Refs Greenstand/treetracker-admin-client#1239
@samwel141
samwel141 force-pushed the feat-admin-wallet-list-1239 branch from aa1b273 to 2d8e413 Compare October 1, 2026 03:46
@dadiorchen
dadiorchen merged commit f621ae0 into Greenstand:keycloak Oct 1, 2026
1 check passed
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.44.0-keycloak.42 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants