This is a very simple approach to doing role-based access control with Neo4j. It is optimistic, in the sense that all items are assumed to be world-readable unless they have specific constraints. Item visibility can be constrained to either individual users or all users who belong to a role. Roles are also hierarchical, so can inherit privileges from other roles.
First, lets create our basic example data:
CREATE
(admin { type: 'role', name: 'admin'}),
(role1 { type: 'role', name: 'role1'}),
role1-[BELONGS_TO]->admin,
(user1 { type: 'user', name: 'user1'}),
user1-[BELONGS_TO]->role1,
(role2 { type: 'role', name: 'role2'}),
(user2 { type: 'user', name: 'user2'}),
user2-[BELONGS_TO]->role2,
(item1 { type: 'item', name: 'item1'}),
item1-[ACCESSIBLE_TO]->admin,
(item2 { type: 'item', name: 'item2'}),
item2-[ACCESSIBLE_TO]->role2
RETURN admin, role1, role2, user1, user2, item1, item2
Hi @mikesname! This looks nice! Did you use it in a real project, did you run into any issues (performance, manageability or whatnot)?