If hook_entity_operations adds Payments with no permission check, it'll show up in e.g. a view of orders that might be available to a user who shouldn't be seeing anything to do with payments. This patch adds a permission check for "administer payments"

Comments

ransomweaver created an issue. See original summary.

ransomweaver’s picture

ransomweaver’s picture

Status: Active » Needs review
mglaman’s picture

  requirements:
    _permission: 'administer commerce_payment'

The route has permission definitions. Shouldn't core filter out that route?

Nope.

\Drupal\Core\Render\Element\Operations -> \Drupal\Core\Render\Element\Dropbutton -> links theme hook -> template_preprocess_links

Nowhere in the rendering does it check link access before rendering. Nor does the Link render element which gets defined in the build array. Both field_ui_entity_operation and content_translation_entity_operation check access before returning a link.

So I guess this is the right way.

mglaman’s picture

Status: Needs review » Needs work
+++ b/modules/payment/commerce_payment.module
@@ -47,15 +47,18 @@ function commerce_payment_entity_base_field_info(EntityTypeInterface $entity_typ
+    $current_user = \Drupal::currentUser();
+    if ($current_user->hasPermission('administer payments')) {

The actual permission is administer commerce_payment

ransomweaver’s picture

StatusFileSize
new1.12 KB

True!

ransomweaver’s picture

Status: Needs work » Needs review
bojanz’s picture

Status: Needs review » Fixed

Thanks!

  • bojanz committed 503ca92 on 8.x-2.x authored by ransomweaver
    Issue #2916549 by ransomweaver: Check permissions before adding payments...

Status: Fixed » Closed (fixed)

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