Entity API Change record: https://www.drupal.org/node/3002038

We need a way to secure all entity lists (not just nodes) for entities that can be grouped. So node grants is not the best option and Entity
API has recently come up with a way that allows us to alter queries more easily. Let's investigate that route or write our lightweight version of it until core supports something similar.

Comments

kristiaanvandeneynde created an issue. See original summary.

arosboro’s picture

@kristiaanvandeneynde do you have any WIP for this effort? I'd be happy to review.

kristiaanvandeneynde’s picture

Tentatively scheduled for this month (Jan 2019).

kristiaanvandeneynde’s picture

chertzog’s picture

Lending my voice to help as needed.

kristiaanvandeneynde’s picture

Simple group query access has landed in a child issue (and as a result the dev branch). Note: requires Entity API.

bdurbin’s picture

Hi @kristiaanvandeneynde Is this something that's already in the works, or are you looking for patches? Our team would be happy to help move this one forward, especially if it's the last remaining feature-level issue blocking a full release.

kristiaanvandeneynde’s picture

Hi, I currently have a feature branch open for this. I did get sidetracked on the permission layer (again), but am hoping to complete it soon.

What we still need:

  1. A GroupContent query access handler akin to the Group one
  2. A query alter event that applies group permissions to any groupable entity type

See #3035067: Add query access to Group entity lists for the work that has landed so far.

bdurbin’s picture

Thanks for the context. The GroupContent query access handler based on the Group one makes sense. Would you mind guiding us a bit more on what you mean by a "query alter event"? It looks like hook for altering entity queries isn't yet back in D8. Is there some alternative within events that you had in mind?

kristiaanvandeneynde’s picture

It's the event that allows you to alter the results generated by query access handlers. It's part of Entity API.

mikran’s picture

Hi kristiaanvandeneynde,

Is that feature branch publicly available somewhere? I couldn't see it on https://git.drupalcode.org/project/group/branches at least.

kristiaanvandeneynde’s picture

It got merged into RC3 already for Group entities. We need one for GroupContent and any generic content entity managed by a group now. See https://git.drupalcode.org/project/group/blob/8.x-1.x/src/Entity/Access/...

mikran’s picture

Issue summary: View changes
moshe weitzman’s picture

kristiaanvandeneynde’s picture

Status: Closed (duplicate) » Active

Reopening as this issue is specifically about finishing the query access handlers and nothing else.

kristiaanvandeneynde’s picture

Status: Active » Needs review
StatusFileSize
new17.21 KB

Here's a work-in-progress. It adds a handler for the GroupContent entities, but no tests yet. Posting here so people can review early and perhaps spot any errors while I write the tests.

kristiaanvandeneynde’s picture

+++ b/src/Entity/Access/GroupContentQueryAccessHandler.php
@@ -0,0 +1,210 @@
+      $sub_condition->addCondition('gid', $allowed_any_ids[CGPII::SCOPE_GROUP]);

That's a typo, should be own ids. Will fix as I add tests.

kristiaanvandeneynde’s picture

StatusFileSize
new26.21 KB

Adds tests but still needs an any-vs-own permission test.

kristiaanvandeneynde’s picture

Status: Needs review » Needs work

Will reroll this one with the latest permission provider work.

kristiaanvandeneynde’s picture

Status: Needs work » Needs review
StatusFileSize
new28.7 KB

This takes care of the GroupContent query access. Will see whether I can make any improvements for the memberships and group nodes (if need be).

kristiaanvandeneynde’s picture

Status: Needs review » Reviewed & tested by the community

Seems like the membership and group node queries should work just fine as the former will check for admin permissions and the latter basically extends the default permission provider 100%. I'll add an admin check to the test and call it a day.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Fixed

And fixed.

Status: Fixed » Closed (fixed)

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

ajayg’s picture

Now this is fixed a while ago, what is preventing the official release of 8.1?

kristiaanvandeneynde’s picture

2 patches in Entity API are blocking us. See the related issue: https://www.drupal.org/project/group/issues/3134072

ajayg’s picture

perhaps you should add on the roadmap link or main project page it is blocking the release of 8.1.