Support from Acquia helps fund testing for Drupal Acquia logo

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.

shadcn’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Active » Needs review
FileSize
10.59 KB

OK here we go.

We have the same access issue here. So this adds an access handler to \Drupal\rdf\Entity\RdfMapping.

Let's see what fails.

Status: Needs review » Needs work

The last submitted patch, 3: entityresource_provide-2843771-3.patch, failed testing.

Wim Leers’s picture

  1. +++ b/core/modules/rdf/src/RdfMappingAccessControlHandler.php
    @@ -0,0 +1,29 @@
    + * Defines the access control handler for the rdf mapping entity type.
    

    s/rdf/RDF/

  2. +++ b/core/modules/rdf/src/RdfMappingAccessControlHandler.php
    @@ -0,0 +1,29 @@
    +    // Allow all users to view vocabulary config entities.
    

    This is not for vocabulary config entities.

  3. +++ b/core/modules/rest/tests/src/Functional/EntityResource/RdfMapping/RdfMappingJsonAnonTest.php
    @@ -0,0 +1,24 @@
    +class NodeTypeJsonAnonTest extends RdfMappingResourceTestBase {
    

    s/NodeType/RdfMapping/

    This is why the test failed :)

  4. +++ b/core/modules/rest/tests/src/Functional/EntityResource/RdfMapping/RdfMappingResourceTestBase.php
    @@ -0,0 +1,137 @@
    +/**
    + * ResourceTestBase for RdfMapping entity.
    + */
    ...
    +   * The RdfMapping entity.
    

    These comments are pointless, and inconsistent with the others. But I don't care enough to insist on them being removed.

shadcn’s picture

Status: Needs work » Needs review
FileSize
10.44 KB
2.24 KB

Thanks for the review Wim.

1. Done.
2. Removed.
3. Fixed. Thanks.
4. I do. Removed them. Let's keep things consistent :)

Status: Needs review » Needs work

The last submitted patch, 6: entityresource_provide-2843771-6.patch, failed testing.

Wim Leers’s picture

+++ b/core/modules/rest/tests/src/Functional/EntityResource/RdfMapping/RdfMappingResourceTestBase.php
@@ -0,0 +1,132 @@
+    $llama = rdf_get_mapping('node', 'camelids');

One more thing. Let's replace this with:

RdfMapping::create([
  'targetEntityType' => 'node',
  'bundle' => 'camelids',
]);

Then it's far more clear what's happening. Also consistent with the rest. No more magic!

shadcn’s picture

Status: Needs work » Needs review
FileSize
10.54 KB
1.02 KB

Done. Thanks.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/rdf/src/RdfMappingAccessControlHandler.php
@@ -0,0 +1,28 @@
+    if ($operation === 'view') {
+      return AccessResult::allowedIfHasPermission($account, 'access content');
+    }

I think we need an issue to discuss the applicability of this permission to config entities. It doesn't feel right. See #2843772-15: EntityResource: Provide comprehensive test coverage for DateFormat entity

Wim Leers’s picture

Title: EntityResource: Provide comprehensive test coverage for RdfMapping entity » [PP-1] EntityResource: Provide comprehensive test coverage for RdfMapping entity
Status: Needs work » Postponed
Wim Leers’s picture

Title: [PP-1] EntityResource: Provide comprehensive test coverage for RdfMapping entity » EntityResource: Provide comprehensive test coverage for RdfMapping entity
Status: Postponed » Reviewed & tested by the community
FileSize
2.91 KB
9.25 KB

Consensus was achieved! Quoting #2870018-35: Should the 'access content' permission be used to control access to viewing configuration entities via REST:

  1. config entities that do not yet have an access control handler nor an admin_permission (RdfMapping, Tour): add an admin_permission.
  2. update all access control handlers for entity types that currently grant access without requiring any permission (View, Menu, File, DateFormat): change them to require the entity type's admin_permission or the entity-type specific "view" permission (yet to be added), so for example: AccessResult::allowedIfHasPermissions($account, ['view menu', 'administer menu'], 'OR').

It seemed reasonable to use the same administer site configuration as the admin_permission for the RdfMapping config entity type, since \Drupal\Core\Datetime\Entity\DateFormat does this too, and it's very similar site builder-wise, and editing frequency-wise.

alexpott’s picture

Title: EntityResource: Provide comprehensive test coverage for RdfMapping entity » EntityResource: Add an admin permission to RdfMapping entity and provide comprehensive test coverage
Issue summary: View changes

Rehashing title and issue summary to cover scope

alexpott’s picture

Category: Task » Bug report

This is a bug fix because the config entity should not be exposed to users without the admin permission via REST or JsonAPI.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed f135eb2 to 8.4.x and b986493 to 8.3.x. Thanks!

Backported to 8.3.x to close the anon access and for the additional test coverage.

  • alexpott committed f135eb2 on 8.4.x
    Issue #2843771 by arshadcn, Wim Leers: EntityResource: Add an admin...

  • alexpott committed b986493 on 8.3.x
    Issue #2843771 by arshadcn, Wim Leers: EntityResource: Add an admin...
Wim Leers’s picture

Status: Fixed » Closed (fixed)

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