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

Reject reserved realm role names (release/10.0) - #3689

Merged
BelSequent merged 5 commits into
release/10.0from
fix/meta-13843/release/10.0
Nov 12, 2026
Merged

BelSequent merged 5 commits into
release/10.0from
fix/meta-13843/release/10.0

Conversation

@edulix

@edulix edulix commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

Summary

Permission names (Keycloak realm roles) can no longer be created, assigned to a role or imported under names the platform keeps for itself: admin, service-account, datafix-account, super-admin-user and cli-account-admin.

  • sequent-core: RealmRolePolicy classifies a name as ordinary or reserved, ignoring case and surrounding whitespace. KeycloakAdminClient refuses to create a permission or a role with a reserved name, and refuses to assign a permission when the role Keycloak resolves is reserved, however the request spelled its name.
  • harvest: create-permission, set-role-permission and create-role answer 400 Bad Request for a reserved name, before calling Keycloak.
  • windmill: the roles and permissions CSV of a tenant config import is checked before anything is changed.

Removing a reserved permission from a role, or deleting it, works as before.

Validation

  • cargo test -p sequent-core --features keycloak,default_features --lib (237 passed)
  • cargo test -p harvest --bins (18 passed)
  • cargo test -p windmill --lib services::keycloak (8 passed)
  • The new tests fail on the previous code and pass now. Ordinary permission names are covered by tests that create, assign and import them, and by a check of every role and group permission in the default tenant realm template.
  • cargo fmt --check, reuse lint

Deploy notes

No migration. Permissions that already exist are not modified. A tenant config import whose roles file lists a reserved name now fails before changing anything.

Summary by CodeRabbit

  • Bug Fixes
    • Reserved platform-managed permission names are rejected when creating permissions or roles, assigning permissions to roles or groups, and importing or loading role configuration.
    • Checks recognize reserved names regardless of capitalization or surrounding whitespace, including names returned by the identity provider.
    • Rejected operations return an error identifying the reserved name; ordinary permissions remain supported.

edulix and others added 2 commits October 10, 2026 12:16
Cover permission creation, role creation, permission assignment and the
tenant config roles import with reserved and ordinary names.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Add RealmRolePolicy to sequent-core and apply it when a permission or a
role is created, when a permission is assigned to a role, and when the
roles and permissions of a tenant config are imported. The Keycloak admin
client checks the names it is given and the role Keycloak resolves them
to; harvest answers 400 for a reserved name.

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

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds a shared policy for five reserved Hasura role names and applies it to Harvest permission and role routes, Keycloak permission and role operations, and Windmill role configuration and imports. Validation checks requested names and, during role assignment, names returned by Keycloak.

Changes: Reserved Permission Validation

Layer / File(s) Summary
Define reserved-role policy
packages/sequent-core/src/types/permissions.rs, packages/sequent-core/src/services/authorization.rs
The policy classifies five reserved names case-insensitively and ignores surrounding whitespace. The authorization helper maps policy errors to BadRequest.
Validate Harvest permission and role routes
packages/harvest/src/routes/permissions.rs, packages/harvest/src/routes/roles.rs
The routes validate permission names before permission creation, role assignment, and role creation. Tests check that reserved names return BadRequest.
Validate Keycloak permission and role operations
packages/sequent-core/src/services/keycloak/permission.rs, packages/sequent-core/src/services/keycloak/role.rs, packages/sequent-core/src/services/keycloak/{mod.rs,test_support.rs}
Permission creation, role assignment, and role creation validate requested or fetched names before Keycloak mapping or creation requests. Tests use a local fake Keycloak server.
Validate Windmill role configuration and imports
packages/windmill/src/services/keycloak.rs, packages/windmill/src/services/import/import_tenant_config.rs
The roles-config reader validates pipe-delimited permissions from CSV before initializing Keycloak clients. Tenant-config imports validate role files before applying entries when roles are selected.

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

Suggested reviewers: findeton, maya-byle

Merge Risk: Minimal · up to d570d

No actionable risk introduced by this change remains after normal checks.

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: rejecting reserved realm role names.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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.
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 14eeef7 and d570dba.

Files selected for processing: 4

  • packages/sequent-core/src/services/keycloak/mod.rs
  • packages/sequent-core/src/services/keycloak/permission.rs
  • packages/windmill/src/services/import/import_tenant_config.rs
  • packages/windmill/src/services/keycloak.rs

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

@edulix

edulix commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 10, 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.

BelSequent and others added 3 commits November 3, 2026 10:14
# Conflicts:
#	packages/sequent-core/src/services/keycloak/permission.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1cadc1a)
@BelSequent
BelSequent marked this pull request as ready for review November 10, 2026 14:33
@BelSequent
BelSequent requested a balanced review from Copilot November 10, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the shared reserved-permission validation changes.

No open issues 🎉

What changed in this PR

This PR adds shared validation for platform-reserved permission names across Keycloak operations, Harvest endpoints, and Windmill tenant imports. Existing permission removal and deletion behavior remains unchanged.

Changes:

  • Classifies reserved names regardless of case or surrounding whitespace and validates names returned by Keycloak.
  • Rejects reserved permissions in API requests and checks selected roles CSV files before applying tenant imports.
  • Adds regression tests for reserved-name rejection and ordinary-name acceptance, supported by a local fake Keycloak server.
File Description
packages/​windmill/​src/​services/​keycloak.rs Validates CSV permissions before Keycloak operations.
packages/​windmill/​src/​services/​import/​import_tenant_config.rs Checks selected roles files before applying import entries.
packages/​sequent-core/​src/​types/​permissions.rs Defines reserved-name policy, errors, and classification tests.
packages/​sequent-core/​src/​services/​keycloak/​test_support.rs Adds a fake Keycloak server that records test requests.
packages/​sequent-core/​src/​services/​keycloak/​role.rs Rejects reserved permissions during group-backed role creation.
packages/​sequent-core/​src/​services/​keycloak/​permission.rs Guards permission creation and single or bulk assignment.
packages/​sequent-core/​src/​services/​keycloak/​mod.rs Registers the test-only support module.
packages/​sequent-core/​src/​services/​authorization.rs Maps reserved-name validation failures to HTTP 400.
packages/​harvest/​src/​routes/​roles.rs Validates permissions before creating roles.
packages/​harvest/​src/​routes/​permissions.rs Rejects reserved names before creating or assigning permissions.

Review effort: Balanced

BelSequent added a commit that referenced this pull request Nov 10, 2026
…-13843/release/10.0)

Squash of the PR's own changes at d570dba (release/10.0...fix/meta-13843/release/10.0),
without the release/10.0 commits merged into the topic branch.

#3689

Related: sequentech/meta#13833

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BelSequent
BelSequent merged commit 922c1df into release/10.0 Nov 12, 2026
36 checks passed
@BelSequent
BelSequent deleted the fix/meta-13843/release/10.0 branch November 12, 2026 13:11
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.

3 participants