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

fix: Gate trustee and tenant-id user attributes (ovcs) - #4244

Open
BelSequent wants to merge 3 commits into
ovcsfrom
fix/meta-13924/ovcs
Open

BelSequent wants to merge 3 commits into
ovcsfrom
fix/meta-13924/ovcs

Conversation

@BelSequent

@BelSequent BelSequent commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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

Port of the release/10.0 fix (#3606). create-user needs trustee-write when the request gives the new user a trustee, and edit-user when it gives an existing user a trustee other than the current one, compared in any order. An edit that sends back the current value needs only the usual permissions and leaves trustee out of the update, so it can't undo a change made after the check. A trustee among the encrypted voter attributes always needs trustee-write. The attribute name is a new shared TRUSTEE_ATTR_NAME in sequent-core, and the sequent-core WASM package is regenerated.

On ovcs the create and edit permissions live in services/access.rs (create_user_permissions, edit_user_access, plus trustee_edit_permission for the edit's comparison with the stored user), and edit-user reads the user through the identity port. ovcs already refuses any client tenant-id on create-user (reject_tenant_id_attribute), so that half of the 10.0 fix is not ported. ovcs user imports check restricted columns against the importer's permissions, so a non-empty trustee cell now also needs trustee-write (TrusteePolicy in ImportUsersPrivileges), for user imports and for the voters file of an election event import; release/10.0 has no such import check. The users and roles permissions page documents the rules.

Validation: new tests in tests/support/access_policy.rs (create with a trustee, plain and encrypted, changed and unchanged trustees in any order, edits without one, import privileges), route_permissions.rs cases for both routes, route tests in account_audit_routes.rs against a scripted Keycloak (an unchanged trustee passes with user-write and a later Keycloak value is kept; a new one is refused without trustee-write and written with it; a failed read is refused), trustee_cells_require_allowed_policy in windmill's import_users.rs, and the updated import privilege tables in user_task_orchestration.rs and insert_election_event.rs. The port was not built or run outside CI (the fix was tested on release/10.0) and relies on this PR's CI. python3 -m scripts.dev.wasm --check-package passes for the regenerated package.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Trustee values now follow dedicated permission checks when creating or editing users and when importing users. Setting a non-empty value requires trustee-write access; unchanged values and empty import cells do not require that additional permission.
    • Import errors for unauthorized trustee values now identify the affected row and column.
  • Documentation
    • Updated the user and import permission guidance to explain trustee access requirements.

BelSequent and others added 2 commits November 12, 2026 12:51
create-user, edit-user and user imports now need trustee-write to give a
user's `trustee` attribute a new value, including through encrypted
attributes. An edit that sends back the current value needs only the usual
permissions and leaves `trustee` out of the update.

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

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds trustee-write checks for trustee attributes during user creation, edits, and imports. It adds import privilege data for trustee values, updates the import validation behavior, and adds tests and documentation for these permission rules.

Changes: Trustee permission handling

Layer / File(s) Summary
Creation and edit permission checks
packages/sequent-core/src/types/keycloak.rs, packages/harvest/src/services/access.rs, packages/harvest/src/routes/users.rs, packages/harvest/tests/support/access_policy.rs, packages/harvest/tests/support/account_audit_routes.rs, packages/harvest/tests/support/route_permissions.rs, docs/docusaurus/docs/02-election_managers/02-reference/user-manual/users-and-roles/users-and-roles_permissions.md
Creation and edit checks require TRUSTEE_WRITE when a trustee value changes or is set as a secret attribute. The edit route reads the current user and omits an unchanged trustee value from the update. Tests cover permission decisions, update payloads, and Keycloak read failures.
Import privilege and cell validation
packages/windmill/src/services/import/import_users.rs, packages/harvest/src/services/access.rs, packages/harvest/src/routes/insert_election_event.rs, packages/harvest/tests/support/access_policy.rs, packages/harvest/tests/support/user_task_orchestration.rs
Import privileges include a trustee policy. The importer accepts non-empty trustee cells only when the policy allows them, and accepts empty cells. Import privilege mapping, fixtures, and tests include the trustee policy.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant edit_user
  participant Keycloak
  participant trustee_edit_permission
  Caller->>edit_user: Submit user edit
  edit_user->>Keycloak: Read current user
  Keycloak-->>edit_user: Return current attributes
  edit_user->>trustee_edit_permission: Compare requested and current trustee values
  trustee_edit_permission-->>edit_user: Return permission or remove unchanged trustee
  edit_user->>edit_user: Authorize TRUSTEE_WRITE when required
  edit_user->>Keycloak: Send user update
Loading

Possibly related PRs

  • sequentech/step#3680: Introduces the ImportUsersPrivileges contract and privilege assignment that this change extends with trustee policy.

Suggested reviewers: edulix, ereslibre

Merge Risk: Minimal · up to a3be8

This PR adds trustee-write checks to user creation, editing and import. No actionable merge-blocking risk remains. Concurrent edits of one user can still overwrite each other, as they could before this change.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: Gate trustee and tenant-id user attributes (ovcs)" names the main change: access checks for the trustee attribute on user creation, user edits, and imports. The PR objectives say the t…
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: Title check

Explanation

The title "fix: Gate trustee and tenant-id user attributes (ovcs)" names the main change: access checks for the trustee attribute on user creation, user edits, and imports. The PR objectives say the tenant-id part of the 10.0 fix is not ported, so the title overstates that aspect. It is still a real part of the change, so the title is partially related and passes under the criteria.

Finishing Touches

Generate unit tests (beta)

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

Warning

CI annotation context is incomplete: annotation collection unavailable or limited

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 934dc7d and a3be871.

Files ignored due to path filters: 1

  • packages/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing: 14

  • docs/docusaurus/docs/02-election_managers/02-reference/user-manual/users-and-roles/users-and-roles_permissions.md
  • packages/admin-portal/rust/sequent-core-0.1.0.tgz
  • packages/ballot-verifier/rust/sequent-core-0.1.0.tgz
  • packages/harvest/src/routes/insert_election_event.rs
  • packages/harvest/src/routes/users.rs
  • packages/harvest/src/services/access.rs
  • packages/harvest/tests/support/access_policy.rs
  • packages/harvest/tests/support/account_audit_routes.rs
  • packages/harvest/tests/support/route_permissions.rs
  • packages/harvest/tests/support/user_task_orchestration.rs
  • packages/sequent-core/src/types/keycloak.rs
  • packages/ui-core/rust/sequent-core-0.1.0.tgz
  • packages/voting-portal/rust/sequent-core-0.1.0.tgz
  • packages/windmill/src/services/import/import_users.rs

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

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.2

QR code for preview link

🚀 View preview at
https://docs.sequentech.io/docusaurus/pr-preview/pr-4244/

Built to branch doc-previews at 2026-11-12 14:25 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
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