Write privilegesEnterprise Edition
This section explains how to use Cypher® to manage write privileges on graphs.
Write privileges are defined for different parts of the graph:
-
CREATE- allows creating nodes and relationships. -
DELETE- allows deleting nodes and relationships. -
SET LABEL- allows setting the specified node labels using theSETclause. -
REMOVE LABEL- allows removing the specified node labels using theREMOVEclause. -
SET PROPERTY- allows setting properties on nodes and relationships.
There are also compound privileges which combine the above specific privileges:
-
MERGE- allowsMATCH,CREATEandSET PROPERTYto apply theMERGEcommand. -
WRITE- allows allWRITEoperations on an entire graph. -
ALL GRAPH PRIVILEGES- allows allREADandWRITEoperations on an entire graph.
|
More details about the syntax descriptions can be found here. |
The CREATE privilege
The CREATE privilege allows a user to create new node and relationship elements on a graph.
See the Cypher CREATE clause.
GRANT CREATE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to grant the role regularUsers the ability to CREATE elements on the graph neo4j, use:
GRANT CREATE ON GRAPH neo4j ELEMENTS * TO regularUsers
The CREATE privilege can also be denied:
DENY CREATE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to deny the role regularUsers the ability to CREATE nodes with the label foo on all graphs, use:
DENY CREATE ON GRAPH * NODES foo TO regularUsers
|
If the user attempts to create nodes with a label that does not already exist on the database, then the user must also possess the CREATE NEW LABEL privilege. The same applies to new relationships: the CREATE NEW RELATIONSHIP TYPE privilege is required. |
The DELETE privilege
The DELETE privilege allows a user to delete node and relationship elements on a graph.
See the Cypher DELETE clause.
GRANT DELETE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to grant the role regularUsers the ability to DELETE elements on the graph neo4j, use:
GRANT DELETE ON GRAPH neo4j ELEMENTS * TO regularUsers
The DELETE privilege can also be denied:
DENY DELETE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to deny the role regularUsers the ability to DELETE relationships with the relationship type bar on all graphs, use:
DENY DELETE ON GRAPH * RELATIONSHIPS bar TO regularUsers
|
Users with |
The SET LABEL privilege
The SET LABEL privilege allows you to set labels on a node using the SET clause:
GRANT SET LABEL { * | label[, ...] }
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to grant the role regularUsers the ability to SET any label on nodes of the graph neo4j, use:
GRANT SET LABEL * ON GRAPH neo4j TO regularUsers
|
Unlike many of the other |
The SET LABEL privilege can also be denied:
DENY SET LABEL { * | label[, ...] }
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to deny the role regularUsers the ability to SET the label foo on nodes of all graphs, use:
DENY SET LABEL foo ON GRAPH * TO regularUsers
|
If no instances of this label exist on the database, then the CREATE NEW LABEL privilege is also required. |
The REMOVE LABEL privilege
The REMOVE LABEL privilege allows you to remove labels from a node by using the REMOVE clause:
GRANT REMOVE LABEL { * | label[, ...] }
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to grant the role regularUsers the ability to REMOVE any label from nodes of the graph neo4j, use:
GRANT REMOVE LABEL * ON GRAPH neo4j TO regularUsers
|
Unlike many of the other |
The REMOVE LABEL privilege can also be denied:
DENY REMOVE LABEL { * | label[, ...] }
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, denying the role regularUsers the ability to remove the label foo from nodes of all graphs, use:
DENY REMOVE LABEL foo ON GRAPH * TO regularUsers
The SET PROPERTY privilege
The SET PROPERTY privilege allows a user to set a property on a node or relationship element in a graph by using the SET clause:
GRANT SET PROPERTY "{" { * | property[, ...] } "}"
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to grant the role regularUsers the ability to SET any property on all elements of the graph neo4j, use:
GRANT SET PROPERTY {*} ON HOME GRAPH ELEMENTS * TO regularUsers
The SET PROPERTY privilege can also be denied:
DENY SET PROPERTY "{" { * | property[, ...] } "}"
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to deny the role regularUsers the ability to SET the property foo on nodes with the label bar on all graphs, use:
DENY SET PROPERTY { foo } ON GRAPH * NODES bar TO regularUsers
|
If the user attempts to set a property with a property name that does not already exist on the database, the user must also possess the CREATE NEW PROPERTY NAME privilege. |
The MERGE privilege
The MERGE privilege is a compound privilege that combines TRAVERSE and READ (i.e. MATCH) with CREATE and SET PROPERTY.
This is intended to enable the use of the MERGE command, but it is also applicable to all reads and writes that require these privileges.
GRANT MERGE "{" { * | property[, ...] } "}"
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
[
ELEMENT[S] { * | label-or-rel-type[, ...] }
| NODE[S] { * | label[, ...] }
| RELATIONSHIP[S] { * | rel-type[, ...] }
]
TO role[, ...]
For example, to grant the role regularUsers the ability to MERGE on all elements of the graph neo4j, use:
GRANT MERGE {*} ON GRAPH neo4j ELEMENTS * TO regularUsers
It is not possible to deny the MERGE privilege.
If you wish to prevent a user from creating elements and setting properties: use DENY CREATE or DENY SET PROPERTY.
|
If the user attempts to create nodes with a label that does not already exist on the database, the user must also possess the CREATE NEW LABEL privilege. The same applies to new relationships and properties - the CREATE NEW RELATIONSHIP TYPE or CREATE NEW PROPERTY NAME privileges are required. |
The WRITE privilege
The WRITE privilege allows the user to execute any WRITE command on a graph.
GRANT WRITE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to grant the role regularUsers the ability to WRITE on the graph neo4j, use:
GRANT WRITE ON GRAPH neo4j TO regularUsers
|
Unlike the more specific |
The WRITE privilege can also be denied:
DENY WRITE
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to deny the role regularUsers the ability to WRITE on the graph neo4j, use:
DENY WRITE ON GRAPH neo4j TO regularUsers
|
Users with |
The ALL GRAPH PRIVILEGES privilege
The ALL GRAPH PRIVILEGES privilege allows the user to execute any command on a graph:
source, syntax, role="noheader"]
GRANT ALL [ [ GRAPH ] PRIVILEGES ]
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to grant the role regularUsers ALL GRAPH PRIVILEGES on the graph neo4j, use:
GRANT ALL GRAPH PRIVILEGES ON GRAPH neo4j TO regularUsers
|
Unlike the more specific |
|
The |
The ALL GRAPH PRIVILEGES privilege can also be denied:
DENY ALL [ [ GRAPH ] PRIVILEGES ]
ON { HOME GRAPH | GRAPH[S] { * | name[, ...] } }
TO role[, ...]
For example, to deny the role regularUsers all graph privileges on the graph neo4j, use:
DENY ALL GRAPH PRIVILEGES ON GRAPH neo4j TO regularUsers