Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently permissions apply across all Media entity bundles, however I would like the ability to allow anonymous users to View a specific Bundle without being able to view another bundle.
Comment | File | Size | Author |
---|---|---|---|
#19 | 2824747-19.patch | 5.93 KB | jefuri |
#13 | 2824747-13.patch | 6.28 KB | jhedstrom |
|
Comments
Comment #2
Deciphered CreditAttribution: Deciphered commentedAs a workaround, I'm currently using a Page manager page with page access to only allow the viewing of the specific bundle.
Comment #3
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedVery valid feature request in my opinion.
Comment #4
Deciphered CreditAttribution: Deciphered commentedComment #5
BerdirThe entity module now provides an entity access control handler with per-bundle permissions, you just need to opt-in to that.
What it doesn't provide yet is any sort of query alter/grant system that would allow to filter lists of media.
Comment #6
Deciphered CreditAttribution: Deciphered at Realityloop commented@Berdir,
Is there an action required in regards to comment #5? It reads a little ambiguous.
The patch seems to provide the required functionality, and it sounds like changing to Entity wouldn't necessarily do so, but if I need to refactor the patch so it will get accepted I'm willing.
Comment #7
BerdirSee #2801031: Provide a generic entity access handler and permissions.
"and it sounds like changing to Entity wouldn't necessarily do so". Yes, it does just as much as your patch. What it doesn't do is grants, but neither does your patch.
We already depend on entity module, and if everything is working as promised, then this patch just needs to add/update the annotation a bit as shown in the EnhancedEntity test example and either update the current access control handler or maybe even completely drop it and we get per-bundle permissions out of the box for free.
Comment #8
JamesK CreditAttribution: JamesK at Advisor Websites commentedHere's a patch with the approach from #7
Comment #10
chr.fritschSeems we need an entity module release to get the tests green.
The new patch is not considering the media->status variable anymore. That should be fixed
Comment #11
jhedstromThis is a reroll of #8 since tests moved to phpunit-based ones, but also I needed to update some of the permissions in the access test to account for how the entity access handler is working (and this also entailed making the
Media
entity implementEntityOwnerInterface
to replace the custom ownership handling in the removed media access controller).Comment #13
jhedstromRemoving the version requirement for the entity module to get tests running for now.
Comment #15
jhedstromAh, I guess that doesn't work--so yeah, we'll need entity to cut a new release and bump up the minimum version here.
Comment #16
BerdirWe also need to be careful to not move away too far from what core has in regards to #2831274: Bring Media entity module to core as Media module (which does the EntityOwnerInterface too and many other things). But this doesn't exist in core yet. We'd need to get that in first and that might delay it quite a bit.
Comment #17
JamesK CreditAttribution: JamesK at Advisor Websites commentedEntity API released a new alpha so the tests pass now.
Comment #18
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedSince this is very likely that Media entity will end up in core very soon and that there is a similar issue for core (#2809177: Introduce entity permission providers) this is likely Won't fix.
Comment #19
jefuri CreditAttribution: jefuri as a volunteer and at Synetic commentedReroll against the latest release, for people still depending on this.