Problem/Motivation

ParagraphsBrowserForm does not check access correctly. Users will still be presented types that they are forbidden to create.

Steps to reproduce

Set up Paragraphs browser for a paragraphs field. Implement a custom entity create access hook for Paragraphs that will deny creation access to a bundle that is allowed to be added to the field, such as:

function hook_paragraph_create_access(\Drupal\Core\Session\AccountInterface $account, array $context, string $entity_bundle) {
  return $entity_bundle === 'mybundle'
    ? \Drupal\Core\Access\AccessResult::forbidden()
    : \Drupal\Core\Access\AccessResult::neutral();
}

Then use the paragraphs browser widget. On the modal form, you will still see 'mybundle' as an option to add. You will get an error if you try to actually click it to add the forbidden type - so access is still denied, it's just not good UX.

Proposed resolution

Instead of a conditional that hardcodes checking certain permissions that are specifically from the paragraphs_type_permissions submodule of Paragraphs, the standard Drupal entity access handler should be used.

Remaining tasks

MR & review.

User interface changes

Users will no longer be able to see.

API changes

Data model changes

Command icon 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

bvoynick created an issue. See original summary.

bvoynick’s picture

Status: Active » Needs review
Related issues: +#2808113: Fix permissions to routes and check access on paragraph bundles

Opened MR 6 with proposed resolution.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Security improvements

  • bvoynick committed 2452e367 on 8.x-1.x
    fix: #3374267 Browser form does not respect entity access
    
    By: bvoynick...
bvoynick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the review! Rebased & merged.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.