1

I am trying to do this without hook_node_grants because, for some reason, it messes with the nodes that are being controlled by the 'Group' module. The Group module itself used to use Node grants, but they got rid of all of its implementations back in July of this year.

For my use case, in addition to grouped nodes, I need private nodes that can allow for access based on field values. And right now to achieve this I am using hook_node_access in a custom module.

The issue with this is that it doesn't work for all the other things, like views and I do not know how many others there are. So, this I'd like to know:

Is there a way to do the access checks once and have them enforced everywhere? ( is hook_access_query_alter the way to do it)?

If there isn't a unified way to go about it? How many access checks should be implemented for a secure approach?

5
  • 1
    Does this answer your question? Having views respect hook_node_access
    – No Sssweat
    Commented Dec 25, 2020 at 6:53
  • 1
    Sadly no. My question is about how to achieve the same thing mentioned in that question but without using that one method mentioned in the answers. I apologize if my question was not clear enough.
    – Jed_BH
    Commented Dec 25, 2020 at 13:42
  • I guess you could do similar to Exclude specific nodes from a view based on role permissions and unset (remove) the view result row if user doesn't have view access.
    – No Sssweat
    Commented Dec 25, 2020 at 14:08
  • I am using something like that, butlooking for a better approach, hence this. Here is something that I have been looking at gorannikolovski.com/blog/… Not sure if the same can be applied to node content types. and this too prometsource.com/blog/… Would extending NodeAccessController do it?
    – Jed_BH
    Commented Dec 25, 2020 at 22:58
  • 1
    Sometimes hook_query_node_access_alter can be useful, if you want to apply custom access control to node queries. Commented Dec 27, 2020 at 10:05

0

Browse other questions tagged or ask your own question.