Repository navigation
Reject reserved realm role names (release/10.0) - #3689
Conversation
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>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
# Conflicts: # packages/sequent-core/src/services/keycloak/permission.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 1cadc1a)
There was a problem hiding this comment.
🟢 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
…-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>
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-userandcli-account-admin.sequent-core:RealmRolePolicyclassifies a name as ordinary or reserved, ignoring case and surrounding whitespace.KeycloakAdminClientrefuses 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-permissionandcreate-roleanswer400 Bad Requestfor 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)cargo fmt --check,reuse lintDeploy 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