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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Deciphered created an issue. See original summary.

Deciphered’s picture

As a workaround, I'm currently using a Page manager page with page access to only allow the viewing of the specific bundle.

slashrsm’s picture

Issue tags: +D8Media

Very valid feature request in my opinion.

Deciphered’s picture

Status: Active » Needs review
FileSize
10.65 KB
Berdir’s picture

The 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.

Deciphered’s picture

@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.

Berdir’s picture

Status: Needs review » Needs work

See #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.

JamesK’s picture

Status: Needs work » Needs review
FileSize
8.04 KB

Here's a patch with the approach from #7

Status: Needs review » Needs work

The last submitted patch, 8: 2824747-8.patch, failed testing.

chr.fritsch’s picture

Seems 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

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
3.39 KB
5.93 KB

This 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 implement EntityOwnerInterface to replace the custom ownership handling in the removed media access controller).

Status: Needs review » Needs work

The last submitted patch, 11: 2824747-11.patch, failed testing.

jhedstrom’s picture

Status: Needs work » Needs review
FileSize
353 bytes
6.28 KB

Removing the version requirement for the entity module to get tests running for now.

Status: Needs review » Needs work

The last submitted patch, 13: 2824747-13.patch, failed testing.

jhedstrom’s picture

Ah, I guess that doesn't work--so yeah, we'll need entity to cut a new release and bump up the minimum version here.

Berdir’s picture

We 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.

JamesK’s picture

Status: Needs work » Needs review

Entity API released a new alpha so the tests pass now.

slashrsm’s picture

Status: Needs review » Closed (won't fix)

Since 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.

jefuri’s picture

FileSize
5.93 KB

Reroll against the latest release, for people still depending on this.