Block content permissions required to select or upload new Media with media library when using Layout Builder

Created on 14 January 2020, almost 5 years ago
Updated 23 May 2024, 6 months ago

Media Library + Layout Builder issue.

To select or upload a media from the media library, user requires administer block content, OR create $bundle block content,access block library.

When using media library widget from within the block content form of a layout builder inline block, where the block content has not yet been
saved
, when the user tries to click insert on the modal (select existing), or try to use the uploader, media_library.module's
MediaLibraryFieldWidgetOpener::checkAccess attempts to call createAccess which eventually gets to BlockContentAccessControlHandler::createAccess which checks for administer blocks.

In normal use of LB / Inline block user does not need this administer permission. Granting this permission is not granular enough to consider granting to lesser users.

Ultimately users should be able to select media from the library, or upload new media, without needing an administer permission. Layout builder provides a create and edit custom blocks for using inline blocks without requiring users to have administer.

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
Layout builderΒ  β†’

Last updated about 7 hours ago

Created by

πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

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

    ✨ Add more granular block content permissions Fixed Would have resolved this. You just need the ability to edit the block content type the media is attached to now. This used to require administer blocks, but no longer does.

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

    While we can use the create * block content permissions to get around this, it's a bit strange because a role doesn't need any of these permissions to actually manage block content inside layout builder at all.

    This means we need to give roles create permissions for blocks they can create in layout builder, only for media library access. But then they'd have access to create them via block/add/foo as well? Leaning on the side of reopening this one.

  • Status changed to Active over 1 year ago
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Yeah, you also need "access block library" which again may not be desirable.

  • πŸ‡ΊπŸ‡ΈUnited States luke.leber Pennsylvania

    I agree with #31 here.

    Our particular use case is that we only want a higher echelon of users to be able to create / edit / delete reusable blocks (due to how far-reaching their usage might be), while allowing lower users to manage inline blocks.

    As it stands, even with contrib module helpers, users still seem to need create permission on the block type in order to use the media library for inline blocks. This comes with the nasty side-effect of allowing them to create reusable blocks as well.

  • πŸ‡³πŸ‡ΏNew Zealand john pitcairn

    I also agree with #31.

    Content editors who should only interact with blocks via layout builder should not see the reusable blocks overview page or be able to create standalone reusable blocks from there.

  • πŸ‡©πŸ‡ͺGermany ammaletu Bonn, Germany

    We just stumbled upon a new variant of this bug (Drupal 10.1.7): Our users have the "administer blocks" permission, but not the new per content block permissions nor the "Access the Content blocks overview page" permission. Everything worked fine for them with Drupal 9. Since the update, they are not able to add media to a block anymore.

    The error message which is logged when clicking on the "Insert" button in the media modal (no error shown to the user):

    Path: [URL with many parameters]. Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: The following permissions are required: 'create gallery_widget block content' AND 'access block library'. in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (line 118 of /var/www/html/web/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

    The change record β†’ for the new permissions sounded as if they were optional, as long as users have the "administer blocks" permission. Now it seems, this has changed so that you do need the new permissions for adding media items to a block!?

  • πŸ‡ΊπŸ‡ΈUnited States ian.ssu

    ian.ssu β†’ made their first commit to this issue’s fork.

  • πŸ‡ΊπŸ‡ΈUnited States ian.ssu

    I spent an entire day with the debugger trying to find an elegant solution to this issue. My conclusion is that LayoutBuilder InlineBlock, by adding the Reusable property to BlockContentEntity, creates a separation of concerns problem. This approach couples BlockContent to LayoutBuilder in ways that other modules, like MediaLibrary, shouldn't have to worry about. I've started considering extending BlockContentEntity for InlineBlock as a potential path toward a solution.

    Unable to come up with a quick solution, I pivoted back to the workaround for Drupal 10.2.6
    https://git.drupalcode.org/issue/drupal-3106315/-/compare/11.x...3106315...

Production build 0.71.5 2024