Per form based access permissions

Created on 13 May 2016, about 8 years ago
Updated 27 February 2023, over 1 year ago

Problem/Motivation

There is a use-case where you need per-form access control

Proposed resolution

Add a 'protect' option to the contact form third party settings.
Add a new permission for each contact form with 'protect' = TRUE
Add a new access controller for viewing contact_form entities
Use the base permission for those with protect = FALSE and the specific one for those with protect = TRUE
Add a new test
Make it in a sub-module.

Remaining tasks

Patch
Tests
Review

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
    1. +++ b/modules/contact_permissions/contact_permissions.module
      @@ -0,0 +1,61 @@
      +  $entity_types['contact_form']->setAccessClass('\Drupal\contact_permissions\ContactFormAccessControlHandler');
      

      we also need to switch the permissions route provider from EntityPermissionsRouteProviderWithCheck to EntityPermissionsRouteProvider

    2. +++ b/modules/contact_permissions/src/ContactPermissions.php
      @@ -0,0 +1,55 @@
      +class ContactPermissions {
      

      This needs to use \Drupal\Core\Entity\BundlePermissionHandlerTrait now so that we get the correct dependencies

Production build 0.69.0 2024