Skip to content

feat(organizations): let a user request to join an existing organization - #681

Merged
dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-org-binding-1266
Oct 20, 2026
Merged

dadiorchen merged 1 commit into
Greenstand:keycloakfrom
samwel141:feat-org-binding-1266

Conversation

@samwel141

@samwel141 samwel141 commented Oct 19, 2026 •

Copy link
Copy Markdown

Part of Greenstand/treetracker-admin-client#1266.

Problem

A registered user can only create a new organization. There is no way to join one that exists.

Change

Five endpoints, storage is two Keycloak user attributes written by the admin client that already writes organization_id, so no table and no realm change:

  • POST /organizations/{id}/binding-requests submits, refused if the user already belongs
  • GET /organizations/binding-requests/me for the home page
  • GET /organizations/binding-requests?skip=&limit= lists pending with a total, admin only
  • POST /organizations/binding-requests/{userId}/approve assigns the claim and the org role
  • POST /organizations/binding-requests/{userId}/reject leaves both alone

Status is its own attribute because Keycloak matches attributes exactly, so the pending list is one query instead of one per organization. Keycloak also caps results at 100 when max is absent, so the list always passes first and max and reports the true total from users/count.

Verification

7 unit tests, plus every path against Keycloak 24 locally: submit, read back, admin list, approve (fresh token carried organization_id and org), the already-belongs 403, and reject.

Paging checked with 120 pending requests: total reports 120, the default page returns 10, and skip=100 returns the last 20, which the unpaged version could not reach.

Deploy

Keycloak: wherever organization_id is permitted as a user attribute, permit organization_binding_request and organization_binding_status too.

Two Keycloak user attributes hold the request, written by the admin client
that already writes organization_id, so no table and no realm change. A
Greenstand admin lists the pending ones, then approves, which assigns the
organization claim and role, or rejects.

Keycloak drops unknown attributes silently when the realm's user profile
disallows them, so the write is read back before reporting success.
@dadiorchen
dadiorchen merged commit e89b38c into Greenstand:keycloak Oct 20, 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