Problem/Motivation
Module always show/clone/create new entity option regardless of the entity_clone permissions.
Proposed resolution
Change entity_clone_entity_access process to validate correctly
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 3067006-19.patch | 8.91 KB | upchuk |
| #18 | 3067006-18.patch | 5.19 KB | upchuk |
| #17 | 3067006-17.patch | 5.16 KB | upchuk |
| #16 | 3067006-16.patch | 5.16 KB | upchuk |
| #13 | interdiff_7-13.txt | 650 bytes | rade |
Comments
Comment #2
keopxHere patch
Comment #3
tuwebo commentedHello,
Patch is working for me. Under operations y don't see "Clone" link. Thanks!
Comment #4
averagejoe3000Applied patch against 1.0.0-beta3 and it's working perfectly for me.
+1 RTBC
Comment #5
deaom commentedI could not re-create the issue. I created a new role Editor, which had clone permission set to "Clone all Menu entities.". When I logged in with the user that has the role Editor I could not clone the content, just the menus. Looking at the provided patch, it does exactly the same as what the code without the patch does, except it adds additional cache contexts. Not sure if the problem was caching as I did not have the problem. So leaving it as needs review and letting somebody else to test it also.
Comment #6
strozx commentedHi, @keopx can you post the steps to reproduce this issue I'm having the same problems as @DeaOm.
Regards
Comment #7
spadxiii commentedDid a quick reroll against latest dev
Comment #8
anybodyRe #5 and #6 I can also confirm this problem. It's simple to reproduce for example with blocks and nodes:
Comment #9
guilhermevp commentedWas able to reproduce the error following the steps of comment #8 and the patch #7 is able to fix it.
Before patch, user "a"shouldn't be able to clone block contents, but them are:
After the patch, user can't clone block content:
Comment #10
nicolas s. commentedpatch #7 works for me
Comment #11
paulmckibbenConfirming #7 fixes the issue for me.
In my case, an anonymous user was allowed to clone certain entity types. This patch prevents it.
Comment #12
gregglesUpdating priority and tags given the access bypass identified in comment #11. Fixing the access bypass should block a full 1.0 release of the module.
Comment #13
rade commentedWhile patch #7 works, it does not check if the user has permission to create the entities. See issue #3011466: Respect the entity create permission.
Attached an improvement which should solve both issues.
Comment #14
pankajsachdeva commentedPatch #13 is working fine. Marking it to RTBC
Comment #15
pankajsachdeva commentedComment #16
upchuk commentedIt's a good point that the user needs to have access to create the entity but we should use the access handler for checking the create access.
Here is a patch that checks this and also a kernel test for testing the access to the route.
Please take a look.
Comment #17
upchuk commentedForgot the test in the wrong namespace.
Comment #18
upchuk commentedForgot the test group as well of course. Let's see what else fails now.
Comment #19
upchuk commentedYeah, broke some existing tests. Fixed with adding permissions.
Encountered also some entity types which don't have a say in their access control handler as to how a user can get an allowed access returned, so for those, I added an exception to the check for create access.
Comment #20
sinn commentedPatch #19 fixes the issue when entity without clone permission was able to be cloned (see example with Block content above).
Also it takes into account "create" entity permission - if user can't create an entity, he won't be able to clone the entity.
Comment #21
joevagyok commentedI reviewed the #19 patch. Works correctly for me, and the create permission was a necessary addition.
Comment #23
upchuk commentedMerged.
Comment #24
upchuk commentedCrediting.