Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

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 reordering
  • manage-layers/ - View check (READ_METADATA_LAYER), create/delete checks for layer operations

Medium-priority components - Added view-only permission gates:

  • project-export/, project-layers/, project-metadata/ - View checks for READ_METADATA_PROJECT and READ_METADATA_LAYER
  • project-permissions/ - View check for READ_PERMISSION
  • update-metadata/ - View check (READ_METADATA_PROJECT) and edit check (UPDATE_METADATA_PROJECT)

Pattern applied:

async connectedCallback() {
    TPEN.attachAuthentication(this)
    
    const hasViewAccess = await CheckPermissions.checkViewAccess('PAGE', 'METADATA')
    if (!hasViewAccess) {
        this.shadowRoot.innerHTML = `<p>You don't have permission to view pages</p>`
        return
    }
    
    // Continue rendering...
}

// For operations
const hasEditAccess = await CheckPermissions.checkEditAccess('PAGE', 'METADATA')
if (!hasEditAccess) {
    TPEN.eventDispatcher.dispatch("tpen-toast", {
        status: "error",
        message: "You don't have permission to manage pages"
    })
    return
}

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

  1. Manage Pages Component (Manage Pages Permissions #178)

    • File: /components/manage-pages/index.js
    • Required permissions:
      • View: READ_METADATA_PAGE, READ_ORDER_PAGE
      • Edit: CREATE_*_PAGE, UPDATE_METADATA_PAGE, UPDATE_ORDER_PAGE, DELETE_*_PAGE
    • The component currently loads and allows all operations without checking permissions
  2. Manage Layers Component (Manage Layers Permissions #179)

    • File: /components/manage-layers/index.js
    • Required permissions:
      • View: READ_METADATA_LAYER, READ_ORDER_LAYER
      • Edit: CREATE_*_LAYER, UPDATE_METADATA_LAYER, UPDATE_ORDER_LAYER, DELETE_*_LAYER
    • The component currently loads and allows all operations without checking permissions

Medium Priority - Needs Verification or Completion

  1. Project Details Component (Project Details Permissions #184)

    • File: /components/project-details/index.js
    • Required permissions:
      • View: READ_METADATA_PROJECT, READ_CONTENT_PAGE, READ_*_MEMBER, READ_*_ROLE
    • Status: Partially implemented - has some checks but may need completion
    • Currently has: checkViewAccess('PROJECT') and checkEditAccess('PROJECT', 'METADATA')
  2. Project Export Component (Project Export Permissions #185)

    • File: /components/project-export/
    • Required permissions:
      • View: READ_METADATA_PROJECT
  3. Project Layers Component (Project Layers Permissions #186)

    • File: /components/project-layers/
    • Required permissions:
      • View: READ_METADATA_LAYER
  4. Project Metadata Component (Project Metadata Permissions #187)

    • File: /components/project-metadata/
    • Required permissions:
      • View: READ_METADATA_PROJECT
  5. Project Options Component (Project Options Permissions #188)

    • File: /components/project-options/
    • Required permissions:
      • View: READ_METADATA_PROJECT, READ_OPTIONS_PROJECT, READ_METADATA_PAGE, READ_*_TOOLS
  6. Project Permissions Component (Project Permissions Permissions #190)

    • File: /components/project-permissions/
    • Required permissions:
      • View: READ_*_PERMISSION, READ_*_ROLE
  7. Update Metadata Component (Update Project Metadata Permissions #200)

    • File: /components/update-metadata/
    • Required permissions:
      • View: READ_METADATA_PROJECT
      • Edit: UPDATE_METADATA_PROJECT

Interface-Level Checks

  1. Manage Project Interface (Manage Project Interface Permissions #205)

    • File: /interfaces/manage-project/index.html and /interfaces/manage-project/index.js
    • Status: Already has some implementation but needs verification
    • Current implementation checks permissions for cards but may need enhancement
  2. Project Details Interface (Project Details Interface Permissions #206)

    • File: /interfaces/project/index.html
    • Required permissions:
      • View: READ_METADATA_PROJECT, READ_CONTENT_PAGE, READ_METADATA_MEMBER, READ_*_ROLE
  3. Project Options Interface (Project Options Interface Permissions #207)

    • File: /interfaces/project/options.html
    • Required permissions:
      • View: READ_METADATA_PROJECT, READ_OPTIONS_PROJECT, READ_METADATA_PAGE, READ_*_TOOLS

Implementation Requirements

For each component/interface, implement the following pattern:

  1. Import the CheckPermissions utility:
import CheckPermissions from '../../components/check-permissions/checkPermissions.js'
  1. Check permissions before rendering (for view access):
async connectedCallback() {
    TPEN.attachAuthentication(this)
    
    // Check if user has view permission
    const hasViewAccess = await CheckPermissions.checkViewAccess('ENTITY', 'SCOPE')
    if (!hasViewAccess) {
        this.shadowRoot.innerHTML = `<p>You don't have permission to view this content</p>`
        return
    }
    
    // Continue with normal rendering
    if (TPEN.activeProject?._id) {
        this.render()
    }
    TPEN.eventDispatcher.on('tpen-project-loaded', this.render.bind(this))
}
  1. Check permissions for edit operations (before allowing modifications):
async setupEditButtons() {
    const hasEditAccess = await CheckPermissions.checkEditAccess('ENTITY', 'SCOPE')
    
    if (!hasEditAccess) {
        // Hide or disable edit buttons
        this.shadowRoot.querySelectorAll('.edit-btn').forEach(btn => {
            btn.style.display = 'none'
            // or btn.disabled = true
   ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for you](https://github.com/CenterForDigitalHumanities/TPEN-interfaces/issues/new?title=+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)  coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits December 19, 2025 02:52
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copilot AI changed the title [WIP] Add permission checks for several components in TPEN-interfaces Add permission checks to components lacking access control Dec 19, 2025
Copilot AI requested a review from cubap December 19, 2025 02:57
@cubap cubap marked this pull request as ready for review December 19, 2025 22:12
@cubap cubap merged commit e34b974 into main Dec 19, 2025
@cubap cubap deleted the copilot/add-permission-checks-for-components branch December 19, 2025 22:12
@cubap cubap restored the copilot/add-permission-checks-for-components branch December 22, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manage Pages Permissions

2 participants