Being new to Cypher and Neo4j, I am having trouble constructing my query for my use-case. I am building a simple ACL (access control list) and am looking for a path through permission relationships an up a hierarchy as well. A picture may better explain it:
Key:
Users -> Blue
Groups -> Yellow, Green
Resource Tree -> Red
Now I want to see if a path exists from Bob to the eVar 33 resource where Bob has update access. Because there is a direct path, I can get what I am looking for by running
MATCH p =(usr:Usr)-[:AXO {update: true}]->(aco:ACO)
WHERE usr.name = 'Bob' AND aco.name = 'eVar 33'
RETURN p
But now, Bob is also a member of the Media Mgmt group which grants him read access to the Conversion resource. And because Conversion is further up the resource tree than eVar 33, eVar 33 should inherit this permission. But when I run the same query looking for {read: true}
instead, no path is found. I know this is because I am not allowing traversal through the :IN
and :HAS
relationships, but how can I do this?
I have tried:
MATCH p =(usr:Usr)-[:IN|:HAS|:AXO {read: true}]->(aco:ACO)
WHERE usr.name = 'Bob' AND aco.name = 'eVar 33'
RETURN p
thinking this would allow those relationships to be traversed, but it still does not find a path (because I am not allowing more than a depth of 1?).
So here are my needs:
- Unknown depth of path
- Any path(s) I get back are fine (all I really care about is "Is there a path or not?")
- Must be able to get from a user to a resource AND when an AXO relationship is being followed it must match a property filter.
- Must follow the directed graph (i.g. Bob has no permissions for Analytics)
And no, I do not work for Nike. Just an example use-case here :)