Problem/Motivation

Currently, the Entity Usage Explorer overview page does not have a dedicated permission.
Access to this page cannot be controlled role-wise, which means site administrators cannot restrict or grant access to specific roles.

Steps to reproduce

1. Enable the Entity Usage Explorer module.
2. Log in as a user with a role that does not have the `administer content` permission.
3. Try visiting `/admin/usage/{entity_type}/{entity_id}`.
- The page is not accessible, since only users with the `administer content` permission can currently view it.
4. Go to `/admin/people/permissions`.
- There is no dedicated permission available to grant role-specific access to the Entity Usage overview page.

Proposed resolution

- Add a custom permission: Access Entity Usage overview page.
- Apply this permission to the route `entity_usage_explorer.usage_page`.
- Update `hook_entity_operation()` so that the “Usage” operation link is only shown if the current user has this permission.
- This will allow site administrators to grant or deny access role-wise.

Remaining tasks

- Add the new permission in `entity_usage_explorer.permissions.yml`.
- Update the route definition to require the new permission.
- Update `hook_entity_operation()` to check the permission via `$account->hasPermission()`.
- Test with different roles to ensure the link only appears when permission is granted.
- Add/update automated tests if available.

User interface changes

- A new permission “Access Entity Usage overview page” will appear on the `/admin/people/permissions` page.
- Site admins can assign or revoke this permission per role.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

keshav patel created an issue. See original summary.

keshav patel’s picture

Assigned: keshav patel » Unassigned
Status: Active » Needs review
ambuj_gupta’s picture

Assigned: Unassigned » ambuj_gupta
ambuj_gupta’s picture

StatusFileSize
new298.27 KB
new367.62 KB
new354.99 KB
new351.65 KB

Tested and Reviewed

Testing Results:

Before Patch:

  • No specific user permission was available for the Entity Usage Explorer module.
  • Only the admin user was able to access the page.

After Patch:

  • A dedicated user permission is now available for the Entity Usage Explorer module.
  • After enabling the permission for specific users, those users are able to access the page successfully.

Everything works as expected after applying the patch. Marking this as Reviewed & Tested by the Community.

ambuj_gupta’s picture

Assigned: ambuj_gupta » Unassigned
ambuj_gupta’s picture

Status: Needs review » Reviewed & tested by the community

  • keshav patel committed 33917746 on 1.0.x
    Issue #3543481: Add permission to control role-based access to Entity...
keshav patel’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for a thorough review @ambuj_gupta.

Merging it into branch 1.0.x, release forthcoming.

keshav patel’s picture

Added release and updated the project description along with screenshot.

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.