TJK: Custom roles#7
Open
MatiasArriola wants to merge 10 commits into
Open
Conversation
Introduce ROLE_FACILITY_STOREKEEPER across backend and frontend role catalogs,\nwith migration support for role creation. Enforce role access across multiple layers:\n- Interceptor-level route and API restrictions for denied domains\n- Menu filtering policy for section/action visibility\n- Location chooser and filtered locations compatibility\n- User/role checks hardened via role-name comparisons to avoid enum identity issues Also align purchase order UI actions and session capability flags with the\nnew policy while preserving higher-role precedence behavior.
Introduce ROLE_REGIONAL_WAREHOUSE across backend and frontend role catalogs, including database migration and i18n label updates. Add policy checks in interceptors/services to allow inventory and outbound operations while denying purchasing and inbound movement creation for regional warehouse users. Update menu/session/location chooser and requisition/stock list UI behavior to expose role-aware client state and hide restricted actions.
Implement ROLE_RPC_SUPERUSER as a location-scoped custom policy with highest-role-wins semantics. Wire role plumbing across backend and frontend session context, including migration and i18n. Enforce access through RoleInterceptor allow/deny paths, menu policy filtering, and location-aware role checks. Enable missing write UX paths for purchasing, products, and stocklists while preserving existing restricted-role behavior.
Implement ROLE_REPORTING_USER as a location-scoped operational role with highest-role-wins behavior and explicit policy predicates. Wire role plumbing across backend and frontend (RoleType, JS constants, session payload/reducer, i18n label, location chooser support, and Liquibase role seed migration). Enforce permissions in RoleInterceptor and MegamenuService: deny purchasing, keep reporting/menu visibility for reads, block write/mutation routes, and hide inbound/outbound create actions for reporting users.
- centralize custom role authorization in CustomRolePolicyService - align backend/frontend visibility and route enforcement for custom roles - fix detached-session lazy role access in role-policy/user-role checks - archive openspec change custom-roles-refactor and sync main specs
… session flags Unify custom-role branching behind canonical policy helpers to avoid duplicated role-specific checks and prevent omissions like Reporting User in authenticated routing branches. Delegate megamenu minimum/supplemental role decisions to CustomRolePolicyService, keeping menu rendering focused on composition while policy exceptions stay in one authorization layer. Drop redundant per-role policy booleans from app-context/session state and rely on canonical customRolePermissions payload, then add regression tests for generic hasAnyCustomPolicy behavior, app-context permissions shape, menu role helper decisions (including RPC superuser exceptions), and custom role hierarchy/priority expansion guarantees. Also document frontend runtime requirement in CLAUDE.md: use nvm use 14 before frontend tests/build commands, since this repo’s frontend toolchain is pinned to Node 14 and mismatches cause false-negative test/build failures.
Hide server-rendered and React product write affordances for read-only custom roles by gating create/import/edit/delete controls behind product-management permissions. Includes follow-up fixes from manual testing and review, plus archived OpenSpec documentation updates to keep upstream touch points accurate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 References
📝 Implementation
CustomRolePolicyService.✨ Description of Change
Description:
This PR adds the TJK custom role access model on top of the existing OpenBoxes role system. The change introduces four custom roles and enforces their access across backend controllers/APIs, menu configuration, session permissions, and frontend action visibility.
The main goal is to support location-scoped operational roles with more specific access than the existing core roles, while preventing restricted actions through both UI controls and direct URL/API access.
Permissions matrix:
Key behavior:
🔥 Notes to the tester
Please validate each custom role at a location where the role is assigned:
Follow-up Checks
High Priority: Custom role assignment scope
ROLE_RPC_SUPERUSER.High Priority: Create Stock Request vs Create Inbound Movement
Medium Priority: Legacy JSON allow-lists
JsonControllerstocklist actions.JsonControlleractions.Medium Priority: RPC Superuser product/configuration scope