Repository navigation
fix: Accept tokens without allowed-origins (release/10.0) - #4179
Conversation
Keycloak leaves allowed-origins out of the token of a client with no web origins, which is what tenant realms now give api-key-client and cli-account-admin. JwtClaims required the claim, so Harvest answered 401 to valid tokens. Nothing reads it, so it now defaults to an empty list. Related: sequentech/meta#13863 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ial (release/10.0) (#4222) Parent issue: sequentech/meta#13997 Port of #4156 (release/10.1), with the same code. release/10.0 already has the tenant realm client scoping from #3596. `upsert_realm` hardens the clients that browsers log in to, in every realm (`voting-portal`, `onsite-voting-portal`, `voting-portal-kiosk`, `results-portal`, `admin-portal`): no direct access (password) or implicit grant, PKCE `S256`, Web Origins `+` (the client's own redirect URIs), and no request URIs. Post-logout redirect URIs become `+` too, except on the voting, onsite and kiosk portals: their Finish button logs out to the event's finish URL, which can be another site. `account-console` only redirects to its realm's account pages. `cli-account-admin` becomes the confidential client for scripts and the CLI: it keeps the password grant, now with its secret, takes no browser logins, and gets the `admin-portal` token mappers and default role, so its tokens carry the same Hasura claims. Compatibility: - The portals already send PKCE `S256`, so browser logins are unchanged. - `KEYCLOAK_CLI_CLIENT_ID` is `cli-account-admin` in `.env.development`, `.env.remote-deployment.example` and the airgap `.env`; `KEYCLOAK_CLI_CLIENT_SECRET` already holds that client's secret. - Publishing and voting status changes need gold-ACR tokens, so they keep using `api-key-client` (documented in the API tutorial). - Confidential clients (`ivr-voting`, `api-key-client`, `service-account`, ...) are not changed. - Existing realms keep their settings until migrated with the migration script in beyond (`scripts/keycloak/harden_public_clients.py`, sequentech/beyond#1111; dry run unless `--apply`). `public_client_hardening.md` documents the order: scripts switch to `cli-account-admin` first, then the realms are migrated. Nothing is changed on any deployment by this PR. Merge order: after #4179 (C29's token-claim fix for this release). Without it, Harvest rejects `cli-account-admin` tokens, which carry no `allowed-origins` claim. Validation: the `realm.rs` tests are on #4156 and #4224, where `realm.rs` and its tests are the same; here CI runs them. `development_realm_templates_are_already_hardened` runs `harden_realm_clients` over the tenant and event development templates and expects no change, with the portal clients public and on the code flow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Security** * Browser-based portal sign-ins now require PKCE, and password-based sign-in is disabled for browser clients. * CLI and administrative operations use dedicated client credentials. Administrative tokens include updated role and permission claims. * **Documentation** * Updated setup and API authentication guidance explains the new CLI credentials, token assurance levels, and migration steps for existing realms. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Parent issue: https://github.com/sequentech/meta/issues/13863
Keycloak leaves
allowed-originsout of the token of a client with no web origins. Tenant realms now have two such clients,api-key-client(in the template) andcli-account-admin.JwtClaimsrequired the claim, so Harvest answered 401 to their valid tokens, which Hasura reports asUnknown Error. The claim now defaults to an empty list. Nothing reads it, and token verification is unchanged.Validation:
claims_without_allowed_origins_decode_to_an_empty_listfails without the fix (missing field `allowed-origins`) and passes with it, andclaims_keep_the_allowed_origins_they_carrycovers tokens that have the claim. Both ran onovcs, where the patch is identical. This port relies on its CI and on dev-env test 45.6, which sends a token without the claim through Hasura to Harvest.Hold: this merges only after test 45.6 passes in batch 4.
🤖 Generated with Claude Code
Summary by CodeRabbit