ENG-3137: Fix viewer users unable to edit assigned systems#7754
ENG-3137: Fix viewer users unable to edit assigned systems#7754thabofletcher wants to merge 5 commits intomainfrom
Conversation
The RBAC commit introduced a read-only permission check in SystemInformationForm that was not gated behind the alphaRbac feature flag and only checked for the global SYSTEM_UPDATE scope. This caused viewer users with assigned systems to see a read-only form, even though they should be able to edit via SYSTEM_MANAGER_UPDATE. - Gate the read-only check behind the alphaRbac feature flag so it has no effect when RBAC is disabled - Check both SYSTEM_UPDATE and SYSTEM_MANAGER_UPDATE scopes so viewers with assigned systems can still edit them - Add Cypress regression test for the scenario Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Without this, the test passes vacuously because isReadOnly is gated behind flags.alphaRbac which defaults to false in the test environment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
The fix is clean and the intent is clear. Two issues worth noting:
Critical
None.
Suggestions
Per-system scope check is too coarse (SystemInformationForm.tsx:99): useHasPermission([SYSTEM_UPDATE, SYSTEM_MANAGER_UPDATE]) treats SYSTEM_MANAGER_UPDATE as a global boolean — if it exists anywhere in total_scopes, the form unlocks for every system the user visits, including ones they don't manage. The backend will correctly reject unauthorized saves, but the user will see an editable form and only get an error on submit. The right long-term fix is to compare the current system's fides key against the user's assigned systems list. This is likely out of scope for this regression fix, but worth tracking as a follow-up.
Nice to Have
Misleading // BUG: comments in the Cypress test (lines 61, 64): those comments label the assertions for the fixed behavior, which will cause confusion for anyone reading them later. A quick rename to // FIXED (ENG-3137): or just removing the prefix would help.
Overall the core fix is correct: gating isReadOnly behind flags.alphaRbac restores pre-RBAC behavior when the flag is off, and adding SYSTEM_MANAGER_UPDATE to the scope check unblocks assigned viewers. The Cypress coverage for both the positive and negative case is a good addition.
Greptile SummaryThis PR fixes two related RBAC bugs in
Confidence Score: 5/5
Important Files Changed
Reviews (1): Last reviewed commit: "Add changelog entry for ENG-3137 fix" | Re-trigger Greptile |
clients/admin-ui/cypress/e2e/systems/plus/viewer-assigned-system.cy.ts
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Use ScopeRegistryEnum instead of hardcoded scope strings - Replace misleading "BUG:" comment labels with "Regression guard" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
nrxsmith
left a comment
There was a problem hiding this comment.
This makes sense to me.
We (And I really include myself there, I'll check if there are any Cardea gaps) should double check we don't have similar problems other user types.
Ticket ENG-3137
Description Of Changes
The RBAC management UI commit (
8e9788e) introduced a read-only permission check inSystemInformationFormthat was not gated behind thealphaRbacfeature flag and only checked for the globalSYSTEM_UPDATEscope. This caused two issues:SYSTEM_MANAGER_UPDATEscopeCode Changes
isReadOnlycheck behindflags.alphaRbacso it has no effect when RBAC is disabledSYSTEM_UPDATE(global) andSYSTEM_MANAGER_UPDATE(per-system) scopes so viewers with assigned systems can still edit themviewer-assigned-system.cy.ts) withalphaRbacflag enabled, covering both scenarios:system_manager:updatecan edit assigned system (was broken)Steps to Confirm
alphaRbacfeature flag → system edit form should behave exactly as before (no read-only restrictions)alphaRbacfeature flag → viewer withsystem_manager:updatescope can edit their assigned systemalphaRbacfeature flag → viewer without update scopes sees "Read-only access" alert and disabled formnpx cypress run --spec "cypress/e2e/systems/plus/viewer-assigned-system.cy.ts"Pre-Merge Checklist
CHANGELOG.mdupdated