CommentFileSizeAuthor
#11 interdiff.txt1.16 KBAnonymous (not verified)
#11 rest_filter_format-2843757-11.patch8.78 KBAnonymous (not verified)
#8 interdiff.txt2.27 KBAnonymous (not verified)
#8 rest_filter_format-2843757-8.patch8.96 KBAnonymous (not verified)
#3 rest_filter_format-2843757-3.patch9.37 KBAnonymous (not verified)

Comments

naveenvalecha created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new9.37 KB
+++ b/core/modules/filter/src/FilterFormatAccessControlHandler.php
@@ -21,7 +21,7 @@ protected function checkAccess(EntityInterface $filter_format, $operation, Accou
     /** @var \Drupal\filter\FilterFormatInterface $filter_format */
 
     // All users are allowed to use the fallback filter.
-    if ($operation == 'use') {
+    if ($operation == 'use' || $operation == 'view') {

Can we add 'view' to the 'use' condition?

wim leers’s picture

Status: Needs review » Needs work
Issue tags: +DevDaysSeville
+++ b/core/modules/filter/src/FilterFormatAccessControlHandler.php
@@ -21,7 +21,7 @@ protected function checkAccess(EntityInterface $filter_format, $operation, Accou
-    if ($operation == 'use') {
+    if ($operation == 'use' || $operation == 'view') {

I'm not sure this is desirable. using is very different from viewing. Viewing means you are allowed to see the filters in this text format… which may be sensitive. So I think that for $operation === 'view' you actually only want to grant access if the user has the administer filters permission.

Other than that, this is looking great!

mavillalba’s picture

Assigned: Unassigned » mavillalba
mavillalba’s picture

I'll work in this. I sent to test with the version 8.4.x.

mavillalba’s picture

Assigned: mavillalba » Unassigned
Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new8.96 KB
new2.27 KB

Thanks for the wise advice @Wim Leers! I chose 'use', because not want free permissions to 'view'. But 'administer filters' eliminates this problem of course :)

@mavillalba, thank you for your interest in this issue. Few fails with 8.4.x looks like #2859704: Intermittent segfaults on DrupalCI (some "did not complete due to a fatal error" with no additional info). We should not worry much about random faults here.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect to me :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/filter/src/FilterFormatAccessControlHandler.php
@@ -20,6 +20,10 @@ class FilterFormatAccessControlHandler extends EntityAccessControlHandler {
+    if ($operation === 'view') {
+      return AccessResult::allowedIfHasPermission($account, 'administer filters');
+    }

Is there a generic issue discussing config entity view access? And it is worth considering adding generic behaviour to check the admin permission defined in a config entity' entity type plugin annotation?

Looking more deeply at the code... I think there might be a better fix. We can change:

    if (in_array($operation, ['disable', 'update'])) {
      return parent::checkAccess($filter_format, $operation, $account);
    }

to

    if (in_array($operation, ['disable', 'update', 'view'])) {
      return parent::checkAccess($filter_format, $operation, $account);
    }

Since in the parent class it does:

    if ($admin_permission = $this->entityType->getAdminPermission()) {
      return AccessResult::allowedIfHasPermission($account, $this->entityType->getAdminPermission());
    }

Less hard coding of permission names and more default behaviour...

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new8.78 KB
new1.16 KB

@alexpott, thank you for the help! Your advice looks absolutely compatible with the advice of @Wim Leers about 'administer filters' and definitely has sense. Let's do it.

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

+1!

Good catch, @alexpott :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 4826159 to 8.4.x and 8dfab09 to 8.3.x. Thanks!

I've committed this to 8.3.x because whilst there is a run-time change to FilterFormatAccessControlHandler is makes sense and could be considered a bugfix and has ample test coverage added.

  • alexpott committed 4826159 on 8.4.x
    Issue #2843757 by vaplas, Wim Leers, alexpott: EntityResource: Provide...

  • alexpott committed 8dfab09 on 8.3.x
    Issue #2843757 by vaplas, Wim Leers, alexpott: EntityResource: Provide...

Status: Fixed » Closed (fixed)

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