Skip to content

Commit 9ac4316

Browse files
Add section on limitations around privileges and missing labels (neo4j#1453)
as well as notes on the relevant privileges linking to it --------- Co-authored-by: Reneta Popova <[email protected]>
1 parent be38e7f commit 9ac4316

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

modules/ROOT/pages/authentication-authorization/limitations.adoc

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,61 @@ CALL db.labels()
277277

278278
will only return label `:A`, because that is the only label for which traversal was granted.
279279

280+
[[access-control-limitations-non-existing-labels]]
281+
=== Privileges for non-existing labels, relationship types, and property names
282+
283+
Privileges for non-existent labels, relationship types, and property names have an effect only once the latter are created.
284+
In other words, when authorizing a user, only privileges for existing labels, relationship types, and property names are applied.
285+
This is because the graph elements must be resolved internally to be able to check against the privileges when users try to use them later.
286+
If a label, relationship type, or property name does not yet exist, it will not resolve, and therefore, the privileges will not apply.
287+
288+
A way around this is to create the label, relationship type, or property name using the `db.createLabel()`, `db.createRelationshipType()`, and `db.createProperty()` procedures on the relevant database when creating the privileges.
289+
290+
Labels, relationship types, and property names are considered non-existent in a database if:
291+
292+
* There has never been a node with that label, a relationship with that relationship type, or a property with that name.
293+
* There has been no attempt to add a node with that label, a relationship with that relationship type, or a property with that name. +
294+
The attempted creation adds it to the known labels, relationship types, and property names even if the creation itself fails (unless it fails on missing or denied privileges to create new labels, relationship types, or property names).
295+
* They have not been created using any of the `db.createLabel()`, `db.createRelationshipType()`, or `db.createProperty()` procedures.
296+
297+
There is currently no way to remove a label, relationship type, or property name from the database.
298+
Once existent in the database, they cannot return to non-existent.
299+
300+
For example, let's assume that you have a new, freshly-created empty database, called `testing`, and a user named `Alice` with a `custom` role.
301+
[NOTE]
302+
=====
303+
The example focuses only on nodes and their labels, though the same principle applies to relationships and their relationship type, and properties (on both nodes and relationships) and their names.
304+
=====
305+
306+
Using the following command, you define some privileges to the `custom` role:
307+
[source, cypher]
308+
----
309+
GRANT MATCH {*} ON GRAPH testing NODES * TO custom
310+
GRANT CREATE ON GRAPH testing NODES `A` TO custom
311+
GRANT SET LABEL `A` ON GRAPH testing TO custom
312+
GRANT CREATE NEW NODE LABEL ON DATABASE testing TO custom
313+
----
314+
315+
This means that when `Alice` executes:
316+
317+
[source, cypher]
318+
----
319+
CREATE (:`A`)
320+
----
321+
322+
She will get the following exception even though she is allowed to create new labels:
323+
[source]
324+
----
325+
Create node with labels 'A' on database 'testing' is not allowed for user 'Alice' with roles [PUBLIC, custom].
326+
----
327+
328+
However, rerunning the same query will create the node.
329+
This is because the failed creation still creates the label, making it no longer non-existent when the query is run a second time.
330+
331+
To ensure success on the first attempt, when setting up the privileges for the `custom` role, the administrator should run the `db.createLabel()` procedure on the affected databases for all non-existing labels that get assigned privileges.
332+
In this example, when creating the custom role, connect to `testing` and run `CALL db.createLabel('A')` to ensure Alice creates the node successfully on her first attempt.
333+
334+
280335

281336
[[access-control-limitations-db-operations]]
282337
== Security and count store operations

modules/ROOT/pages/authentication-authorization/privileges-reads.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ For example, we can disable users with the role `regularUsers` from finding all
6767
DENY TRAVERSE ON HOME GRAPH NODES Payments TO regularUsers
6868
----
6969

70+
[NOTE]
71+
====
72+
If a label or a relationship type does not exist in the database, the user cannot use the corresponding privilege until it is created.
73+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
74+
====
75+
7076

7177
[[access-control-privileges-reads-read]]
7278
== The `READ` privilege
@@ -122,6 +128,12 @@ The following example shows how to do that:
122128
DENY READ { secret } ON GRAPH neo4j NODES Post TO regularUsers
123129
----
124130

131+
[NOTE]
132+
====
133+
If a label, a relationship type, or a property name does not exist in the database, the user cannot use the corresponding privilege until it is created.
134+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
135+
====
136+
125137

126138
[[access-control-privileges-reads-match]]
127139
== The `MATCH` privilege
@@ -182,3 +194,9 @@ The following query exemplifies how it would look if you wanted to deny both rea
182194
----
183195
DENY MATCH { * } ON GRAPH neo4j NODES Account TO regularUsers
184196
----
197+
198+
[NOTE]
199+
====
200+
If a label, a relationship type, or a property name does not exist in the database, the user cannot use the corresponding privilege until it is created.
201+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
202+
====

modules/ROOT/pages/authentication-authorization/privileges-writes.adoc

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ If the user attempts to create nodes with a label that does not already exist on
8282
The same applies to new relationships: the xref:authentication-authorization/database-administration.adoc#access-control-database-administration-tokens[`CREATE NEW RELATIONSHIP TYPE`] privilege is required.
8383
====
8484

85+
[NOTE]
86+
====
87+
If a label or a relationship type does not exist in the database, the user cannot use the corresponding privilege until it is created.
88+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
89+
====
90+
8591

8692
[[access-control-privileges-writes-delete]]
8793
== The `DELETE` privilege
@@ -135,6 +141,12 @@ Users with `DELETE` privilege, but restricted `TRAVERSE` privileges, will not be
135141
See href:tutorial/access-control.adoc#detach-delete-restricted-user[delete restricted user] for more info.
136142
====
137143

144+
[NOTE]
145+
====
146+
If a label or a relationship type does not exist in the database, the user cannot use the corresponding privilege until it is created.
147+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
148+
====
149+
138150

139151
[[access-control-privileges-writes-set-label]]
140152
== The `SET LABEL` privilege
@@ -181,6 +193,12 @@ DENY SET LABEL foo ON GRAPH * TO regularUsers
181193
If no instances of this label exist on the database, then the xref:authentication-authorization/database-administration.adoc#access-control-database-administration-tokens[`CREATE NEW LABEL`] privilege is also required.
182194
====
183195

196+
[NOTE]
197+
====
198+
If a label does not exist in the database, the user cannot use the corresponding privilege until it is created.
199+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
200+
====
201+
184202

185203
[[access-control-privileges-writes-remove-label]]
186204
== The `REMOVE LABEL` privilege
@@ -222,6 +240,12 @@ For example, denying the role `regularUsers` the ability to remove the label `fo
222240
DENY REMOVE LABEL foo ON GRAPH * TO regularUsers
223241
----
224242

243+
[NOTE]
244+
====
245+
If a label does not exist in the database, the user cannot use the corresponding privilege until it is created.
246+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
247+
====
248+
225249

226250
[[access-control-privileges-writes-set-property]]
227251
== The `SET PROPERTY` privilege
@@ -273,6 +297,12 @@ DENY SET PROPERTY { foo } ON GRAPH * NODES bar TO regularUsers
273297
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 xref:authentication-authorization/database-administration.adoc#access-control-database-administration-tokens[`CREATE NEW PROPERTY NAME`] privilege.
274298
====
275299

300+
[NOTE]
301+
====
302+
If a label, a relationship type, or a property name does not exist in the database, the user cannot use the corresponding privilege until it is created.
303+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
304+
====
305+
276306

277307
[[access-control-privileges-writes-merge]]
278308
== The `MERGE` privilege
@@ -311,6 +341,12 @@ xref:authentication-authorization/database-administration.adoc#access-control-da
311341
xref:authentication-authorization/database-administration.adoc#access-control-database-administration-tokens[`CREATE NEW PROPERTY NAME`] privileges are required.
312342
====
313343

344+
[NOTE]
345+
====
346+
If a label, a relationship type, or a property name does not exist in the database, the user cannot use the corresponding privilege until it is created.
347+
See xref:authentication-authorization/limitations.adoc#access-control-limitations-non-existing-labels[Privileges for non-existing labels, relationship types, and property names] for more information.
348+
====
349+
314350

315351
[[access-control-privileges-writes-write]]
316352
== The `WRITE` privilege

0 commit comments

Comments
 (0)