Add permission checks to components lacking access control #383
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.
Multiple components were loading and rendering data without validating user permissions, allowing unauthorized users to view and modify project resources.
Changes
High-priority components - Added comprehensive permission gates:
manage-pages/- View check (READ_METADATA_PAGE), edit checks for label updates, page deletion, and reorderingmanage-layers/- View check (READ_METADATA_LAYER), create/delete checks for layer operationsMedium-priority components - Added view-only permission gates:
project-export/,project-layers/,project-metadata/- View checks forREAD_METADATA_PROJECTandREAD_METADATA_LAYERproject-permissions/- View check forREAD_PERMISSIONupdate-metadata/- View check (READ_METADATA_PROJECT) and edit check (UPDATE_METADATA_PROJECT)Pattern applied:
All permission checks use consistent
(entity, scope)parameter ordering and provide user feedback via toast notifications or inline messages.Closes #178, #179, #184, #185, #186, #187, #188, #190, #200, #205, #206, #207
Original prompt
Problem Statement
Several components and interfaces in the TPEN-interfaces repository are missing proper permission checks as documented in issues #178, #179, #184, #185, #186, #187, #188, #190, #200, #205, #206, and #207. These components need to implement permission validation to ensure users have appropriate access levels before viewing or modifying project data.
Background
The permission checking infrastructure already exists in the codebase (
components/check-permissions/checkPermissions.js), which provides methods like:checkViewAccess(entity, scope)checkEditAccess(entity, scope)checkCreateAccess(entity, scope)checkDeleteAccess(entity, scope)However, many components have not yet integrated these permission checks.
Components Requiring Implementation
High Priority - Missing All Permission Checks
Manage Pages Component (Manage Pages Permissions #178)
/components/manage-pages/index.jsREAD_METADATA_PAGE,READ_ORDER_PAGECREATE_*_PAGE,UPDATE_METADATA_PAGE,UPDATE_ORDER_PAGE,DELETE_*_PAGEManage Layers Component (Manage Layers Permissions #179)
/components/manage-layers/index.jsREAD_METADATA_LAYER,READ_ORDER_LAYERCREATE_*_LAYER,UPDATE_METADATA_LAYER,UPDATE_ORDER_LAYER,DELETE_*_LAYERMedium Priority - Needs Verification or Completion
Project Details Component (Project Details Permissions #184)
/components/project-details/index.jsREAD_METADATA_PROJECT,READ_CONTENT_PAGE,READ_*_MEMBER,READ_*_ROLEcheckViewAccess('PROJECT')andcheckEditAccess('PROJECT', 'METADATA')Project Export Component (Project Export Permissions #185)
/components/project-export/READ_METADATA_PROJECTProject Layers Component (Project Layers Permissions #186)
/components/project-layers/READ_METADATA_LAYERProject Metadata Component (Project Metadata Permissions #187)
/components/project-metadata/READ_METADATA_PROJECTProject Options Component (Project Options Permissions #188)
/components/project-options/READ_METADATA_PROJECT,READ_OPTIONS_PROJECT,READ_METADATA_PAGE,READ_*_TOOLSProject Permissions Component (Project Permissions Permissions #190)
/components/project-permissions/READ_*_PERMISSION,READ_*_ROLEUpdate Metadata Component (Update Project Metadata Permissions #200)
/components/update-metadata/READ_METADATA_PROJECTUPDATE_METADATA_PROJECTInterface-Level Checks
Manage Project Interface (Manage Project Interface Permissions #205)
/interfaces/manage-project/index.htmland/interfaces/manage-project/index.jsProject Details Interface (Project Details Interface Permissions #206)
/interfaces/project/index.htmlREAD_METADATA_PROJECT,READ_CONTENT_PAGE,READ_METADATA_MEMBER,READ_*_ROLEProject Options Interface (Project Options Interface Permissions #207)
/interfaces/project/options.htmlREAD_METADATA_PROJECT,READ_OPTIONS_PROJECT,READ_METADATA_PAGE,READ_*_TOOLSImplementation Requirements
For each component/interface, implement the following pattern: