Views will display entities the user does not have "view" access permission I have a custom entity type that can be viewed by certain people only. This works just fine, when people go to &quot;mysite.com/custom-entity/8&quot; some can see the info, some get &quot;access denied&quot; error.
The problem is I created a view to display a list of those entities and all of them are shown to all users, even if certain users shouldn't have &quot;view&quot; access permission.
LE: Caching is set to &quot;None&quot;
Any ideas on how to fix this? Thanks.
Option A
Create a custom access handler for your view.
Drupal 8 - Views Custom Access with a Plugin is a great guide. It seems like your scenario may fit the use case outlined in the beginning:
&quot;... prohibit the display of a Drupal 8 View dependent upon some custom rules that don't fit easily with Drupal's permissions model ...&quot;
Pro: You will get exactly the control features you want.
Con: A lot of custom code.
Option B
If you want permission for viewing the entity to be directly tied to the view access, there is an &quot;Access&quot; section on the view configuration form. Select &quot;Permission&quot; and then select the permission for viewing the entity you have created.
Pro: Easy to set up.
Con: Your use case must fit into Drupal's permissions system.