Creating two relationships breaks access

Created on 18 February 2024, about 1 year ago

Problem/Motivation

When creating more than one relationship to the same entity, access is broken.

For the following, assume the following use case
- One "contract" content entity type
- One group type
- Two content relationships: group_contract__seller:default, group_contract__buyer:default

Steps to reproduce

- Create the contract entity type
- Create the contract relationship plugins like described above
- Create a group, a contract, and a "seller" relationship
- Create a view that filters on the "seller" relationship only
(We do not need to add "buyer" group and relationship, having the relationship plugin alone is enough to break access.)

Expected:
- Member of seller group with contract view access can list and view the contract.

Experienced:
- Views access is allowed: Said seller CAN see a contract in the seller view (but is blank for reason below).
- Entity access is forbidden: Said seller can NOT view that contract.

Proposed resolution

(Omitting rant about Drupal 3state access...)
Add Access::Forbidden not in AccessHandler, but in group_entity_access.

Remaining tasks

User interface changes

None.

API changes

AccessHandler change needs a CR.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

3.3

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @geek-merlin
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany
  • Merge request !129Fix multi-relationship access β†’ (Open) created by geek-merlin
  • Status changed to Needs review about 1 year ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    This pushed trivial MR fixes the issue for me.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 786s
    #98136
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany
  • Assigned to geek-merlin
  • Status changed to Needs work about 1 year ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Like so.

  • Pipeline finished with Canceled
    about 1 year ago
    Total: 582s
    #102724
  • Pipeline finished with Failed
    about 1 year ago
    Total: 907s
    #102730
  • Pipeline finished with Failed
    11 months ago
    Total: 1204s
    #182794
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Ah, i see, the testUnsupportedOperation test is still red. Know how to fix this, but this needs a thorough code comment. Freaky 3-state semantics again...

  • Assigned to geek-merlin
  • Status changed to Needs work 11 months ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany
  • Pipeline finished with Failed
    5 months ago
    Total: 1263s
    #342472
  • Pipeline finished with Failed
    5 months ago
    Total: 1323s
    #342635
  • Pipeline finished with Success
    5 months ago
    Total: 1157s
    #342696
  • Issue was unassigned.
  • Status changed to Needs review 5 months ago
  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Here's the correct fix with comments.

  • πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

    I have a view, which isn't returning any results, and seems like it is matching the issue described here as I have two relationships (Group, and Group content user). However, I do not get a resolution with the patch. When logged in as a user, on the page with the view, (/admin/group here), I don't get any results, when logged in as an admin, and in the view editor, if I add the user ID as the contextual filter argument, I do get results. The only filter I have is "Group relationship: Group relationship type". This did previously work in Group 2.2, but breaks on upgrading to 2.3.

    I also tried dropping an xdebug breakpoint on the lines the patch added, and I don't see stopping on those lines at all. I haven't narrowed down if the view is actually getting results out of the query, or if they are being stripped some other way. That's a task for the morning.

  • πŸ‡ΊπŸ‡ΈUnited States bburg Washington D.C.

    So immediately after posting my last comment, I saw that there was a new 2.3.1 release, and a release note to re-run the update hook β†’ . I did so, and it seems to be working now with the patch.

  • πŸ‡ΊπŸ‡ΈUnited States caesius

    To elaborate on my colleague @bburg's comments, we've confirmed that our issue was actually due to a bug specific to 2.3.0; further upgrading to 2.3.1 fixes it. The patch here doesn't seem to be related, nor does the database update hook (which, rather than needing to be re-run, just needs a manual fix to the module schema version so the upgrade path to 3.3.0 executes).

    The actual issue appears to be this item from the release note:

    ... fixes a permissions bug when group_support_revisions was enabled.

    Sorry for the confusion!

  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    Thx for elaborating. To clarify:
    - This is abolut "single" access for a page manager page.
    - It is not related at all to any views "list" access.

  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    Experiencing the same issue, and wondering at the same time why this seems not to happen frequently for other sites. Are most sites only using one relationship on an entity?

  • πŸ‡©πŸ‡ͺGermany geek-merlin Freiburg, Germany

    > Are most sites only using one relationship on an entity?

    Yes, i suppose.

    And: Nice to have you on board here! Did you review or test my approach?

  • πŸ‡©πŸ‡ͺGermany mxh Offenburg

    I took a second look for verification and it seems my problem is somewhere else and is probably unrelated to this. I'm not having more than one group content plugin involved for one particular entity, which seems to be in your case (plugin IDs "group_contract__seller:default", "group_contract__buyer:default")?

    As nodes usually have one plugin ID in use on a group type, for example "group_node:article" this issue may only show up when dealing with multiple plugins. So even when there are multiple roles defined in one group type, still only one plugin ID is in use.

    If the query access logic acts like "if one handler allows access, then access is granted" then yes the loop in group_entity_access needs to be adjusted so that is behaves the same. I took a look into your MR and it might work, just a bit hard to read. Maybe a test that verifies the result between query and runtime access when having multiple plugins involved can make this clear.

Production build 0.71.5 2024