Repository navigation
feat(organizations): let a user request to join an existing organization - #681
Merged
Merged
Conversation
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
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-requestssubmits, refused if the user already belongsGET /organizations/binding-requests/mefor the home pageGET /organizations/binding-requests?skip=&limit=lists pending with a total, admin onlyPOST /organizations/binding-requests/{userId}/approveassigns the claim and theorgrolePOST /organizations/binding-requests/{userId}/rejectleaves both aloneStatus 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
maxis absent, so the list always passesfirstandmaxand reports the true total fromusers/count.Verification
7 unit tests, plus every path against Keycloak 24 locally: submit, read back, admin list, approve (fresh token carried
organization_idandorg), the already-belongs 403, and reject.Paging checked with 120 pending requests:
totalreports 120, the default page returns 10, andskip=100returns the last 20, which the unpaged version could not reach.Deploy
Keycloak: wherever
organization_idis permitted as a user attribute, permitorganization_binding_requestandorganization_binding_statustoo.