BlockContentAccessControlHandler requires access block library permission for update, delete and revisions operations

Created on 18 October 2023, 8 months ago
Updated 4 January 2024, 6 months ago

Problem/Motivation

In ✨ Add Block Content revision UI Fixed we expanded the permissions matrix for Block Content entities, but we added a hard requirement on the access block library permission for all operations.

There are times when you may want editors to be able to edit/delete/revert/view revisions of blocks without having access to the admin listing (collection). The access block library permission is used (by default) as the permission to access the block library. This does not need to be integrated into operation checks for block content entities - just as we don't check for access content overview for node operations.

Steps to reproduce

Install Drupal
Add a role that has edit any basic block content permission
Try to edit a block
Get a 403

Proposed resolution

Remove "access block library" permission check from all operations

Remaining tasks

  1. Fix test failures

Original report

Block edit permissions that were working in D9, don't seem to be working anymore in D10.

In drupal 9 our editors had the following content block permissions:

Type 1: Edit content block
Type 2: Edit content block
Type 3: Edit content block

With these permissions we were able to keep our editors out of the block library, but they could still make the changes they needed.

  1. The edit contextual links were present on blocks they could edit
  2. We were also able to build an admin listing using views that contained the "Bulk operations" field. Editors could use the edit link in the view to edit these Blocks. Important note: This view's "Access" is set to Permission: Type 1: Edit content block

After upgrading to Drupal 10:

  1. The edit contextual links are missing from blocks (for editors)
  2. Editors can still access the block admin listing (so the edit permission works in general), but the edit links are missing from the "Bulk operations" column (so the permissions do not work for editing blocks anymore).

(For developers (the admin role) both edit and delete links are present under "Operations", both in Drupal 9 and in Drupal 10.)

What I tried:

* Does not work: Adding the views field for "Link to edit Content block" -- this link appears for developers (admin role) but not for editors.
* Does not work: Adding the views field for "Block content ID" and rewriting this field as a link /admin/content/block/{{ id }} -- this link appears for editors, but when attempting to edit the block they still get "Access denied" (indicating that the problem is not with generating links, but actually with editing blocks)
* Does work (with consequences): Granting editors the Administer block content permission -- this restores the edit links for editors, but it also adds a delete link, and grants them edit/delete access to additional block types that they should not be able to access.

This problem may have been introduced by changes from https://www.drupal.org/project/drupal/issues/1975064 ✨ Add more granular block content permissions Fixed

πŸ› Bug report
Status

Fixed

Version

10.2 ✨

Component
Block contentΒ  β†’

Last updated 5 days ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jenlampton

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024