Problem/Motivation
Revision operations on CRM contacts and relationships are allowed based only on a global revision permission. They are not combined with view, update, or delete access on that specific entity.
Drupal core node access requires both the revision permission and access to the node (for example, view access to see a revision). CRM does not. A user who is given view crm contact revision (or the relationship equivalent) can open revision pages for contacts they are not allowed to view. Those revisions include personal data such as names and contact methods.
Affected handlers:
Drupal\crm\Access\ContactAccessControlHandler::checkAccess()— operationsview all revisions,view revision,revert,delete revisionDrupal\crm\Access\RelationshipAccessControlHandler::checkAccess()— the same operations
Routes come from core RevisionHtmlRouteProvider, for example /crm/contact/{crm_contact}/revisions/{crm_contact_revision}/view.
Steps to reproduce
- Create two person contacts with identifying data. Give user A view access to only the first contact (for example via mapping or bundle permissions), not the second.
- Grant user A
view crm contact revision(and notadminister crmorview any crm contact). - As user A, visit the revision view URL for the second contact.
Proposed resolution
Mirror node access: AND the revision permission with the matching entity operation.
view revision/view all revisions→ also requireviewon the entityrevert→ also requireupdateon the entitydelete revision→ also requiredeleteon the entity (or the same rule core uses for the entity type)
Preserve cacheability by chaining AccessResult objects (andIf()) rather than converting access to a boolean.
Remaining tasks
- Update both access control handlers.
- Add kernel or functional tests for allowed and denied revision routes.
User interface changes
None, other than revision tabs/links disappearing when the user cannot view the entity.
API changes
None.
Data model changes
None.
Issue fork crm-3622713
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
Comment #4
bluegeek9 commented