Final follow-up to #3013678: Implement the query access handling that was recently added to Entity API
We already have query access for groups and GroupContent entities, now we just need query access for grouped entities.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | group-3134072-19.patch | 52.19 KB | kristiaanvandeneynde |
Comments
Comment #2
kristiaanvandeneyndeMight be blocked by both of these:
And could be improved by #3134160: Support all operations in query access alters
Comment #3
kristiaanvandeneyndeAttached is a proof of concept that requires the two Entity API patches listed above. It hasn't got tests yet, but it shows how we would handle any entity query through this system. If it works, we can do away with node grants altogether.
Comment #4
berdirNote that suddenly enforcing this has a lot of side effects on existing sites. The same for groups broke a lot of our custom queries in cron jobs, tests and drush commands where we didn't have a proper authenticated user context, so we have to disable access checking in all those places.
Sure, that's the point of this change in a way, but it should at least be noted *very* prominently in the release notes then :)
Comment #5
kristiaanvandeneynde@Berdir I've thought of that :)
And the release notes will indeed very prominently explain the new option of a permission provider and the fact that adding one to your plugin, even if only the default one, will automagically make all your entity lists secure.
More on point: having to change your queries is indeed a nuisance we have to get past. It's either have no query access checking and be considered insecure, or have query access checking and require people to update their custom queries so they have proper access checks (or none at all).
Commerce ran into the same issue, which is why Bojan did not want to break core all of a sudden by polyfilling the access handlers for all of core's entity types. See #3086409-2: Provide a default query_access handler for core (maybe all?) entity types
Comment #6
kristiaanvandeneyndeThese lines will ensure no sites break all of a sudden. In the other patch (for the relation aka GroupContent entities), we took the same approach. So only GroupContent queries might break for members and group nodes. And by "break" we mean they will no longer return all members, but only the ones you are allowed to see. So it really boils down to a security fix again.
Comment #7
berdirOk, cool, didn't look at the code yet, just wanted to leave a note about that. Just found another bug in a rarely used drush command this week due to the group access changes :)
Comment #8
kristiaanvandeneyndeThis is the latest version, it has cache tags and deals with the owner properly. Was previously looking for the owner of the group content, whereas it should be looking at the owner of the grouped entities. The beauty of this all is that bundles are taken care of automatically because plugins are bundle-aware :)
Will start writing tests now. I have similar tests in Subgroup, so I'll use those as a starting point.
Comment #10
kristiaanvandeneyndeFails are expected, they relate to the new Entity API code (which we can't require yet until a new Entity API release is out).
Comment #11
dwwComing from #3152324: Add a getPluginIdsByEntityType() method to src/Plugin/GroupContentEnablerManager
Didn't fully review or test anything, but a quick note/nit:
Plugin IDs are strings, not ints, right? This should be
@return string[]no?Comment #12
kristiaanvandeneyndeYup, thanks for that. Found a few bugs while writing tests, will update in the next patch.
Comment #13
kristiaanvandeneyndeNow with working tests and various fixes, as soon as Entity API commits and releases #3086409: Provide a default query_access handler for core (maybe all?) entity types
Comment #15
berdirTemporary patch to test against entity 1.x-dev, once a release is out we'll want to set it to that min release instead.
Comment #17
berdirNote quite green yet, but these all look like kernel test fails where node module isn't enabled, so either just enable it or add a check there?
Comment #18
kristiaanvandeneyndeYeah I added new test-only plugins and that caused the issue. "Documented" this in the test module's info.yml file even though that doesn't do anything and added it to the tests that were failing on it.
Comment #19
kristiaanvandeneyndeReroll, going to commit with the dev dependency for now so I can test/clean up the rest of the release. Will change to entity:1.1 before release.
Comment #21
kristiaanvandeneynde