Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix: Accept tokens without allowed-origins (release/10.0) - #4179

Merged
BelSequent merged 1 commit into
release/10.0from
fix/meta-13863-token-origins/release/10.0
Nov 13, 2026
Merged

BelSequent merged 1 commit into
release/10.0from
fix/meta-13863-token-origins/release/10.0

Conversation

@BelSequent

@BelSequent BelSequent commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Parent issue: https://github.com/sequentech/meta/issues/13863

Keycloak leaves allowed-origins out of the token of a client with no web origins. Tenant realms now have two such clients, api-key-client (in the template) and cli-account-admin. JwtClaims required the claim, so Harvest answered 401 to their valid tokens, which Hasura reports as Unknown 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_list fails without the fix (missing field `allowed-origins` ) and passes with it, and claims_keep_the_allowed_origins_they_carry covers tokens that have the claim. Both ran on ovcs, 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

  • Bug Fixes
    • JWT claims can now be read when the allowed-origins claim is absent; provided values are still preserved.

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>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

JwtClaims.allowed_origins now defaults to an empty list when the claim is missing. Tests verify deserialization with both missing and supplied origins.

Changes: JWT claims

Layer / File(s) Summary
Default and test allowed origins
packages/sequent-core/src/services/jwt.rs
Serde defaults a missing allowed-origins claim to an empty list. Tests cover missing and supplied values.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • sequentech/step#3596: This PR gives selected clients empty web-origin lists. PR #4179 allows tokens without allowed-origins to deserialize.

Suggested reviewers: findeton

Merge Risk: Minimal · up to c0cf7

No actionable merge-blocking risk is established for this narrowly scoped deserialization change.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: accepting tokens that omit the allowed-origins claim.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 731d823 and c0cf726.

Files selected for processing: 1

  • packages/sequent-core/src/services/jwt.rs

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 3 reviews per hour.

@BelSequent
BelSequent merged commit 4fad7cf into release/10.0 Nov 13, 2026
35 checks passed
@BelSequent
BelSequent deleted the fix/meta-13863-token-origins/release/10.0 branch November 13, 2026 16:45
BelSequent added a commit that referenced this pull request Nov 14, 2026
…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>
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