Read privileges
There are three separate read privileges:
-
TRAVERSE
- enables the specified entities to be found. -
READ
- enables the specified properties on the found entities to be read. -
MATCH
- combines bothTRAVERSE
andREAD
, enabling an entity to be found and its properties read.
The TRAVERSE
privilege
Users can be granted the right to find nodes and relationships using the GRANT TRAVERSE
privilege.
GRANT TRAVERSE
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, we can enable the user jake
, who has role 'regularUsers' to find all nodes with the label Post
.
GRANT TRAVERSE ON GRAPH neo4j NODES Post TO regularUsers
0 rows, System updates: 1
The TRAVERSE
privilege can also be denied.
DENY TRAVERSE
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, we can disable the user jake
, who has role 'regularUsers' from finding all nodes with the label Payments
.
DENY TRAVERSE ON DEFAULT GRAPH NODES Payments TO regularUsers
0 rows, System updates: 1
The READ
privilege
Users can be granted the right to do property reads on nodes and relationships using the GRANT READ
privilege.
It is very important to note that users can only read properties on entities that they are enabled to find in the first place.
GRANT READ
"{" { * | property[, ...] } "}"
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, we can enable the user jake
, who has role 'regularUsers' to read all properties on nodes with the label Post
.
The *
implies that the ability to read all properties also extends to properties that might be added in the future.
GRANT READ { * } ON GRAPH neo4j NODES Post TO regularUsers
0 rows, System updates: 1
Granting property |
The READ
privilege can also be denied.
DENY READ
"{" { * | property[, ...] } "}"
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
Although we just granted the user 'jake' the right to read all properties, we may want to hide the secret
property. The following example shows how to do that.
DENY READ { secret } ON GRAPH neo4j NODES Post TO regularUsers
0 rows, System updates: 1
The MATCH
privilege
Users can be granted the right to find and do property reads on nodes and relationships using the GRANT MATCH
privilege.
This is semantically the same as having both TRAVERSE
and READ
privileges.
GRANT MATCH
"{" { * | property[, ...] } "}"
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example if you want to grant the ability to read the properties language
and length
for nodes with the label Message
,
as well as the ability to find these nodes, to a role regularUsers
you can use the following GRANT MATCH
query.
GRANT MATCH { language, length } ON GRAPH neo4j NODES Message TO regularUsers
0 rows, System updates: 2
Like all other privileges, the MATCH
privilege can also be denied.
DENY MATCH
"{" { * | property[, ...] } "}"
ON {DEFAULT GRAPH | GRAPH[S] { * | name[, ...] }}
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
Please note that the effect of denying a MATCH
privilege depends on whether concrete property keys are specified or a *
.
If you specify concrete property keys then DENY MATCH
will only deny reading those properties.
Finding the elements to traverse would still be enabled.
If you specify *
instead then both traversal of the element and all property reads will be disabled.
The following queries will show examples for this.
Denying to read the property ´content´ on nodes with the label Message
for the role regularUsers
would look like the following query.
Although not being able to read this specific property, nodes with that label can still be traversed (and, depending on other grants, other properties on it could still be read).
DENY MATCH { content } ON GRAPH neo4j NODES Message TO regularUsers
0 rows, System updates: 1
The following query exemplifies how it would look like if you want to deny both reading all properties and traversing nodes labeled with Account
.
DENY MATCH { * } ON GRAPH neo4j NODES Account TO regularUsers
0 rows, System updates: 1