- Issue created by @aimevp
- π§πͺBelgium aimevp Belgium
I'm trying to making a merge request but can't figure out why I keep getting access denied in git. So for now here's a patch file...
- Status changed to Postponed: needs info
4 months ago 2:03pm 22 July 2024 - π§πͺBelgium msnassar
Sorry for late answer...
This is not a typo... It is intended to check the access to create/edit the root host entity (in your case the page content type). I recommend to look into this code snippet. Usually, if you have the access to edit the root host entity, you should be able to add/upload new media to it. Please, let me know your finding...
I am hiding your patch as it has a security vulnerability...
- Status changed to Active
4 months ago 2:57pm 22 July 2024 - π§πͺBelgium aimevp Belgium
I'm a bit confused what to do now because clearly the code wasn't working as intended in my case. People who had node edit permission (without create permission) within a group were unable to create new media. Has this been tested in that manner? Or can you think of a reason (bad configuration for example) why this isn't working in my project?
- π§πͺBelgium msnassar
I did quick debug.... I confirm the issue... It seems this is due to the fact that we check for entity create access but not update. See here
I believe, in case the entity is exist, we instead have to check the access to update. You can get the entity and its type from MediaLibraryState e.g.
MediaLibraryState::fromRequest($this->requestStack->getCurrentRequest())
Then to check for the access to update, we useentityAccess
fromDrupal\group\Plugin\Group\RelationHandler
.As soon as I have the time, I will look deeply into it. However, patch is very welcome :)
- Status changed to Needs work
about 1 month ago 2:08pm 14 October 2024