feat(keycloak): opt-in trust_tenant_claim, resolver stays authoritative (#376) [stack 6/11] - #390
Merged
Merged
Conversation
…aim is set (#376) Adds SM_KEYCLOAK_TRUST_TENANT_CLAIM (default off). Tests cover the claim ignored by default, honoured when enabled, never beating the tenants resolver, and keycloak's setup-step opt-out. Documents the setting. Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
Deploying simple-module-python with
|
| Latest commit: |
d6537f7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a27f01a6.simple-module-python.pages.dev |
| Branch Preview URL: | https://tenancy-06-keycloak.simple-module-python.pages.dev |
…t roles (review of #376) - A session's cached tenant_id is dropped unless trust_tenant_claim is on now; the provider reads settings through app.state.keycloak, so saves and the boot-time hydration take effect instead of the register_settings snapshot. - A trusted claim must pass is_valid_tenant_id, else it is ignored. - tenant:* roles produced by role_mapping (or cached in old sessions) are stripped, with one warning per offending role. Claude-Session: https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV
antosubash
added this pull request to stack #397
October 1, 2026 16:14
antosubash
marked this pull request as ready for review
October 1, 2026 16:16
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Closes #376. Stack 6/11 of the tenancy-adoption series (base: #389).
What
trust_tenant_claim(SM_KEYCLOAK_TRUST_TENANT_CLAIM), default false and DB-backed. Only when it is true does the JWTtenant_idclaim reachUserContext.tenant_id. A claim-only install with no resolver can still opt in deliberately.tenantsresolver stays authoritative whatever the setting: a forged claim never wins (tested).register_setup_stepsopt-out.docs/modules/keycloak.mdhas a settings row and a "Tenant claim" section.Not covered (follow-up)
_upsert_user_cachesession-factory question, which the issue marks non-blocking./tenants" test. That behaviour is documented, not tested.Tests
make test-py: 3374 passed. All 39 keycloak tests pass.make lintis clean.https://claude.ai/code/session_01F8RiTBUJQnZmSq56qReZeV