Per form based access permissions

Created on 13 May 2016, over 8 years ago
Updated 27 February 2023, almost 2 years 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

Merge Requests

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

  • First commit to issue fork.
  • Pipeline finished with Failed
    2 months ago
    Total: 269s
    #312735
  • πŸ‡ΊπŸ‡ΈUnited States majorrobot

    This seems like a good feature to replace the Contact Form Permissions module (which appears abandoned and doesn't have a supported release anymore). So I'm excited to see it in progress!

    I've created a fork/MR from @naveenvalecha's patch in #18 and updated core version requirements.

    I've also attempted to address @larowlan's requests in #22.

    +++ 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

    I've added this, as I understand it -- but this is my first time handling permissions in Drupal 8+, so I may have missed something.

    +++ 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 EntityPermissionsRouteProvide

    I'm actually not following this one -- I don't see where EntityPermissionsRouteProviderWithCheck is used. Nor have I been able to figure out the intent of the note with a little research. Happy to make changes if someone could clarify, though.

  • Pipeline finished with Failed
    2 months ago
    Total: 160s
    #312870
  • Pipeline finished with Failed
    2 months ago
    Total: 1266s
    #312907
  • Pipeline finished with Success
    2 months ago
    Total: 262s
    #315449
Production build 0.71.5 2024