After the addition of advanced outsider permissions in #2883238: Move the grolesync module to the main module for outsiders only. gnode_node_grants is not adding grants for advanced outsider permissions.

So if a drupal role is given a permission like 'Entity: View content entities' through the advanced outsider permission the related grant is not being applied from gnode_node_grants.

Comments

yovince created an issue. See original summary.

yovince’s picture

Status: Active » Needs review
StatusFileSize
new3.14 KB

patch attached

yovince’s picture

Status: Needs review » Needs work

The last submitted patch, 2: group-node_grants_advanced_outsider-2929037-2-D8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

yovince’s picture

Status: Needs work » Needs review
StatusFileSize
new3.23 KB

This is better one.

rjg’s picture

#5 is working for me (Drupal Core 8.4)

gleroux02’s picture

Confirmed that #5 is also working for me with Drupal Core 8.4.5

dpagini’s picture

Status: Needs review » Reviewed & tested by the community

I see a few "this is working for me" here, so I'm going to bump this to RTBC status to hopefully get a maintainer review. I am utilizing this patch in the same project as @rjgwiz, above.

dpagini’s picture

Another bump to the top of the issue queue. Could we get some guidance on this patch and if it needs anything to be considered for this project?

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Needs work

This is definitely a bug and should be fixed. However, we have test coverage for the grants, so we need to update those tests proving that the code is currently broken. Feel like you're up for the task @yovince?

alxshell’s picture

Hi all,

I have encountered this bug as well and for my usecase it is a showstopper. So how can I help to get this bug into the next release?

alxshell’s picture

I tried to apply the patch to 8.x-1.0-rc4 and it failed... I corrected it to work with 8.x-1.0-rc4. What to do next?
Sry... I made a mistake. Patch from #5 do apply even for 8.x-1.0-rc4.

jordik’s picture

Status: Needs work » Needs review
garphy’s picture

Access checks must be disabled for the query which list all the groups the user is NOT part of otherwise, depending on site permission configuration, they won't be considered.

   foreach ($group_types as $group_type) {
     // Get the IDs of all the groups the user is not part of for the group type.
     $query = $entity_type_manager->getStorage('group')->getQuery();
+    $query->accessCheck(FALSE);
     $query->condition('type', $group_type->id());
     if (!empty($member_gids)) {
       $query->condition('id', $member_gids, 'NOT IN');

Other than that, it indeed seem to resolve issues I got with outsider permissions not being enforced.

dpagini’s picture

Issue tags: +Needs tests

Based on #10, adding "Needs Tests" tag.

garphy’s picture

This patch fixes an issue introduced by the original patch : the $role_ids array holding all outsider role identifiers must be reinitialized for each considered group type otherwise we're giving user some grants it shouldn't have.

lobsterr’s picture

Issue tags: -Needs tests
StatusFileSize
new13.38 KB
new9.72 KB

Added test cases for advanced outsider roles

kristiaanvandeneynde’s picture

Please verify if #3102384: Make node grants actually use the new permission calculators. fixed this for you by trying the latest dev (or RC5 which goes out today). If it does, we should still commit @LOBsTerr's extra test coverage in this issue.

ayalon’s picture

Why was the line
$query->accessCheck(FALSE);
introduced?
I mean, this basically disabled the access check isn't it?

knowak’s picture

This looks to still be an issue in RC5 as I have a similar issue as https://www.drupal.org/project/group/issues/3101139 where views are not displaying the content to outsiders even though they have permission to view them.

grndlvl’s picture

Status: Needs review » Reviewed & tested by the community

#3102384: Make node grants actually use the new permission calculators. Does not resolve this issue. However, #17 fixes this issue.

@ayalon The reason that $query->accessCheck(FALSE); was added was to retrieve all groups of which the user is not a member. This then loops through everything and checks the outsider permissions and if and only if the outsider permission is set for the group then the outside group is added to the user's node grants.

This works! Thanks everyone!

gorkagr’s picture

Hi, latest patch cannot be applied into the latest version of the module (RC5 nor dev) due to changes made in #3102384
(I dont know if RC5 fixed this or not though)

coderdan’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new10.37 KB

Re-rolled for rc5.

webdrips’s picture

I can confirm the re-roll applied cleanly and worked for me.

strozx’s picture

Status: Needs review » Reviewed & tested by the community

Hello, it works for me too. Thanks

kristiaanvandeneynde’s picture

FYI: I am working on #3134072: Implement the query access handling for grouped entities. When (not if) that lands, there's a high likelihood I will completely remove node grants from gnode in favor of this new system. The only change will be deleting a lot of code as this system would take over "automagically". So there is a very small chance this will get committed as the next release will be 1.0 and is set to include the query access handlers.

In the meantime, if the patch here works for you: Great!

kristiaanvandeneynde’s picture

Node grants are now (finally) gone from the module and the new query access layer properly runs access checks across the board (regardless of language). Please verify with the latest dev version.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Closed (outdated)