-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address reviews in #2809177 #53
base: 8.x-1.x
Are you sure you want to change the base?
Conversation
…tityPermissionProvider.
…olHandler into their base class Also, do not apply `cachePerUser()` for the `$operation any` cases. When `$operation any` is not allowed, it then checks the `$operation own` permissions.
Commit 1 (
|
Because github is terrible for multiple people to collaborate, I had to create my own fork that duplicates @gabesullice's. I've pushed my suggested additional changes there. See https://github.com/wimleers/entity/commits/permission-provider. I'll explain the commits when I'm done. Gabe will be able to pull them into his pull request when he's reviewed them. |
In Gabe's refactor, there was a subtle behavior change that was thankfully caught by the unit test coverage. For an entity that implements In this patch, that subtle (subtle at least in terms of code) edge case is removed. I wanted to say that this is a bug that Gabe introduced. But after looking at the permission provider test coverage, I'm not so sure. Quoting:
Those are all IOW: the test coverage was wrong. It should have granted the |
Before I take this too far, I'd like feedback from @bojanz and @gabesullice. Stopping to work on this for now. |
Note that Entity API needs to maintain BC because it's used by contrib (Commerce, Media). I have pinged @dawehner about the "view own published" move, but as far as I remember, him Berdir and myself agreed on the current version when reviewing the code, because most queries deal with published entities only, making the impact of that permission on cacheability low. On the other hand, it's definitely useful to have it, and core tends to agree (Node, for example). |
Ok so then let's definitely not merge those. Renaming the entity access control handler is fine though, right?
I see. It'd have been very helpful if the rationale behind this was documented somewhere. Because "uncacheable" is tied to "per user" cacheability for sure, and then seeing some things exempted and others not is super super confusing. I once already spent about 2 hours trying to reconstruct the reasoning, see the long blob of text at https://www.drupal.org/project/drupal/issues/2809177#comment-12749733. |
If its wrong to have the cacheability like that, than we do have a security issue in core for that, don't we? |
The previous cacheing logic would not have considered the fact that an entity's owner could be updated _to_ the current account's ID. So, if access was not allowed, but then the owner was set to the account, it would have no effect without a cache clear. I removed the bit about the publishing status because that is not relevant to that particular line. I did an the word "also" to indicate that it operates in conjunction with the status logic above.
Okay, I pulled @wimleers first three commits. I need to dig into his last two, which update tests. Then, I'll refactor in a separate commit to preserve BC for the contrib module. |
…t the "view ($bundle) ($entity_type_id)" permission. The permission providers and their test coverage get this right, the access control handler test coverage gets it wrong.
I stepped through the coverage myself to verify @wimleers conclusion that:
and I agree. When the entity type implements |
…wner permissions are not required.
I think @gabesullice's latest commits addressed @bojanz' concerns WRT breaking BC in the contrib At the same time, they help ensure that the difference between what would end up in core versus what is in contrib is minimal. Hopefully @bojanz sees no more problems? |
I am very confused by the current state of this work.
This means that for the regular ("cacheable") version we no longer check update/delete own/any. I am also nervous about the fact that we're modifying the tests at the same time as doing the refactoring, which means we have no guard against unintentional breaks. We need an issue that applies cacheability fixes (perUser, etc). An issue that expands tests. And then an issue that merges handlers. Doing it all at once is going to take a long time to verify. |
This addresses some of the caching reviews given in #2809177, specifically:
view own unpublished
must becachePerUser()
and therefore isn't very cacheable.$operation any
permissions do not need to be cached per user (caching by theuser.permissions
cache context is enough).It uses a new entity annotation key to factor away the two derivative classes of
EntityAccessControlHandlerBase
which removed quite a bit of code, which was discussed today on a call between @bojanz, @wimleers and myself as something that could be attempted.It renames
EntityAccessControlHandlerBase
toPermissionBasedEntityAccessControlHandler
because that was favored on the aforementioned call.What remains:
Possibly merging
EntityPermissionProvider
andUncacheablePermissionProvider
to better mirror the access control handler.Providing useful
$reason
arguments where appropriate to improve DX.Nits and things.