Skip to content

Add organization members and Keycloak sync functions - #21

Merged
chrisjkuch merged 11 commits into
mainfrom
organization-members
Nov 24, 2026
Merged

chrisjkuch merged 11 commits into
mainfrom
organization-members

Conversation

@chrisjkuch

@chrisjkuch chrisjkuch commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Regenerates the client from PDC 0.43.0, so Organization carries its Keycloak identity, disabled_at, members, and former_members, and adds functions to run PDC's Keycloak sync, which is the only way PDC fills that membership data.

Changes

  • Spec and _generated.py refreshed. Codegen also picked up the sync task models and the allFunders grantee type. Breaking: Organization.keycloak_organization_id is now required.
  • get_organizations walks the organizations bundle.
  • sync_users_from_keycloak and sync_organizations_from_keycloak start a sync task and poll it, raising KeycloakSyncError on failure or timeout.
  • KeycloakClientCredentialsProvider takes an optional scope, since the sync endpoints require kc-admin-api.
  • Seeding's KeycloakAdmin.set_user_enabled enables or disables a Keycloak user.
  • pdc_api.testing adds user_payload, and organization_payload sends the new fields.
  • Permission grants accept the allFunders grantee type. The validator reads each type's required key from one table and treats every other type as keyless. The tests list the expected keys for every grantee type and fail by name when the enum gains one they don't list, as allChangemakers will.
  • README documents the sync functions, the token scope, and set_user_enabled. AGENTS.md asks tests to list an expected outcome for every enum member and assert that list covers the enum; Fail by name when the spec adds a grant context or input type #22 tracks the existing tests that still list them.

Notes

PDC's realm doesn't offer the kc-admin-api scope the sync endpoints need (Keycloak 26.8.2 creates it for new and migrated realms, not imported ones). Until service's realm.json defines it, just/patch_realm.py adds it to the downloaded realm, along with the organization roles the pdc-admin group needs, and warns once upstream defines it so we know to delete the script. CI now starts the stack with just pdc up, so it gets the patch too, and the sync integration test runs instead of skipping.

members is None both when the caller can't see membership and when PDC hasn't synced the org yet.

🤖 Generated with Claude Code

chrisjkuch and others added 3 commits November 24, 2026 07:58
Regenerate from PDC 0.43.0, which adds the Keycloak identity, disabledAt,
members, and formerMembers to Organization and a GET /organizations bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PDC fills its user and organization cache only through POST /users/sync
and /organizations/sync, which need a token with the kc-admin-api scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrisjkuch chrisjkuch changed the title Add organization members and get_organizations Add organization members and Keycloak sync functions Nov 24, 2026
chrisjkuch and others added 5 commits November 24, 2026 08:36
The kc-admin-api scope belongs in the realm (PDC's realm.json and its
Keycloak checklist), not in runtime setup. The sync integration test skips
until Keycloak offers the scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KeycloakAdmin.set_user_enabled lets the sync integration test disable a
member and see PDC mark them disabled. The get_organizations test now checks
the synced organization appears instead of only parsing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The grantee validator rejected any type it didn't name, so a grant to
all funders failed to parse. It now reads the keys each type requires
from one table, treats every other type as keyless, and its tests cover
every PermissionGrantGranteeType.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chrisjkuch and others added 2 commits November 24, 2026 09:41
The grantee tests derived expected keys from the validator's own table,
so a wrong entry passed. They now state the keyed types literally and
still cover every other type as keyless. AGENTS.md says to parametrize
over enums but write expectations as literals. Drop the reference verb
from the changelog; it was already supported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grantee-key and sync-status tests now list an expected outcome for every
enum member, parametrize over that list, and assert it covers the enum.
A new member such as allChangemakers fails one named test until someone
records how it behaves. AGENTS.md states the pattern.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PDC's realm.json lacks the kc-admin-api scope, so the sync integration
test skipped. just/patch_realm.py adds the scope and organization roles
from the pending service realm change, and warns once upstream defines
it. CI now starts the stack with `just pdc up` so it gets the patch too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chrisjkuch

Copy link
Copy Markdown
Collaborator Author

This brings us up to date with 0.43.0, which pulled in two big changes: an allFunders grantee type, and getting organization members from Keycloak via the PDC.

@chrisjkuch
chrisjkuch merged commit fe56205 into main Nov 24, 2026
8 checks passed
@chrisjkuch
chrisjkuch deleted the organization-members branch November 24, 2026 10:10
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.

1 participant