My permissions graph looks like this:
In this situation,
user1
has permission onfolder1
throughGroup1
.user2
has direct permissions without any group, though the user is part ofgroup2
wheregroup2
doesn't have access overfolder1
.user3
has permission through group hierarchy, not the direct group to folder access.
I was able to write separate gremlin queries to determine whether a user has permission through one of the groups and user direct permission.
Checking permission through group
g.V().has('user','userId','user1').emit().repeat(out('member_of'))
.outE('has_permission').has('permission','p1').inV()
.has('folder','folderId','folder1').hasNext()
User-direct permission
g.V().has('user','userId','user2')
.outE('has_permission').has('permission','p1').inV()
.has('folder','folderId','folder1').hasNext()
But I couldn't figure out the logic in a single query which can check both direct and group to see whether the user has permission or not.
Can someone help me out here?