3.4 KiB
3.4 KiB
Task: POS Login & Access Control Hardening
Background
The user wants to ensure that POS_TERMINAL accounts, which are children of a STORE_MANAGER, can:
- Access the POS for the store managed/owned by their parent.
- NOT access the POS or data of other stores outside their parent's hierarchy.
- NOT access features "above" their role (already partially handled by RBAC, but needs verification).
Requirements
- RBAC Verification: Verify that
POS_TERMINALrole contains the necessary permissions but doesn't overreach intoSTORE_MANAGERorSTORE_OWNERterritory. - Cross-Store Access Control: Ensure
PosControllermethods (startSession,getTodayStats,getCustomers,getPosSessions,listHistory) explicitly check if the authenticated user (especiallyPOS_TERMINAL) is authorized for the requestedstore_hash. - Hierarchy Boundary: Ensure
POS_TERMINALcannot access administrative pages or data that their parent (STORE_MANAGER) is restricted from (already base logic, but needs testing). - Testing Suite: Create a comprehensive feature test to simulate the hierarchy and verify access attempts across multiple stores.
Technical Approach
- Store Access Logic:
- Create a static method in
UserPermissionsor a trait to checkisUserAllowedToAccessStore(User $user, Store $store). - Logic:
- IF Ultimate user -> Allow.
- IF $user->id is $store->owner_id or $store->manager_id -> Allow.
- IF $user is an ancestor of $store->owner or $store->manager -> Allow.
- IF $user is a child of the store manager/owner AND role is
POS_TERMINALorRIDER-> Allow.
- Create a static method in
- Controller Hardening:
- Update
app/Http/Controllers/Market/PosController.phpto use this check in all methods receiving astore_hash.
- Update
- Test Case:
tests/Feature/PosAccessTest.phpwill be created to automate these checks.
Impact Analysis
- Refines security for multi-store environments.
- Ensures data isolation among different franchises or store locations.
Verified Findings (as of 2026-04-03)
Based on the audit report in @[docs/tasks/pos-access-control-test-report.md], the following findings have been verified and need to be addressed:
- RBAC Status:
POS_TERMINALhas the necessary base permissions (ViewPosReports,ViewCustomers,ViewUserInfo,ManageUserInfo). - Permission Gap:
STORE_MANAGERis missing theCreateUserPOSTerminalaction permission inUserPermissions::roles(). - Missing Helper:
isUserAllowedAccessToStoreis not implemented inUserPermissions.php. - Controller Security Gaps:
PosController@startSession: No store-level check or authentication for non-terminal logins.PosController@getSession: No store-level check.PosController@getPosSessions: Missing ALL permission/store-level checks.PosController@getTodayStats: Missing store-level check.PosController@getCustomers: Missing store-level check.
- Missing Infrastructure:
isAncestorOfhelper is missing (needed for hierarchical store access). - Missing Tests:
tests/Feature/PosAccessTest.phpdoes not exist. - UI Security:
PosMain.vueis functional but lacks any store-level authorization checks or error handling for unauthorized access. - Performance Optimization:
PosControlleralready usesCacheHelperand raw DB queries in some areas, but these need to be maintained during hardening.