Skip to content

Commit ec11b3d

Browse files
Add 22ND1 and 22ND2 (#412)
https://linear.app/neo4j/issue/COPS-301/update-to-notification-cannot-deny-with-auth-rule The trello/linear template says > Docs for new status code should > have a table with code, title, severity and category But I didn't find one for other codes? Documents error codes introduced in neo-technology/neo4j#33422 --------- Co-authored-by: Reneta Popova <[email protected]>
1 parent ec3e69c commit ec11b3d

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@
175175
**** xref:errors/gql-errors/22NCD.adoc[]
176176
**** xref:errors/gql-errors/22NCE.adoc[]
177177
**** xref:errors/gql-errors/22NCF.adoc[]
178+
**** xref:errors/gql-errors/22ND1.adoc[]
179+
**** xref:errors/gql-errors/22ND2.adoc[]
178180
*** xref:errors/gql-errors/index.adoc#invalid-transaction-state[Invalid transaction state]
179181
**** xref:errors/gql-errors/25G02.adoc[]
180182
**** xref:errors/gql-errors/25N01.adoc[]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
= 22ND1
2+
3+
== Status description
4+
error: data exception - operation not allowed for roles that are granted to an `AUTH RULE`. Invalid input: `'{ <<query>> }'` is not allowed for roles that are granted to an `AUTH RULE`.
5+
6+
== Explanation
7+
8+
If an auth rule fails to evaluate, for example, because it depends on a claim that the user's auth token does not contain, Neo4j will default to not assigning that role to the user.
9+
10+
When a role contains denied privileges, not assigning the role actually removes the denies, which means the user ends up with more privileges than they should.
11+
To avoid this, roles cannot have both `DENY` privileges and be granted to an auth rule.
12+
13+
This exception is thrown when attempting to `DENY` a privilege from a role that is already used by an auth rule.
14+
15+
[[example-scenario-22nd1]]
16+
== Example scenario
17+
18+
Given that a role is used by an auth rule:
19+
[source, cypher]
20+
----
21+
CYPHER 25 GRANT ROLE role TO AUTH RULE authrule
22+
----
23+
24+
When attempting to deny privileges from the role:
25+
[source, cypher]
26+
----
27+
DENY MATCH {*} ON GRAPH secret-db NODES * TO otherrole, role
28+
----
29+
30+
The following error will be thrown:
31+
[source]
32+
----
33+
error: data exception - operation not allowed for roles that are granted to an AUTH RULE. Invalid input: 'DENY MATCH {*} ON GRAPH secret-db NODES * TO role' is not allowed for roles that are granted to an AUTH RULE.
34+
----
35+
36+
[NOTE]
37+
====
38+
The error message contains a subset of the original query that caused the issue.
39+
Since `otherrole` is not granted to an auth rule, it is not included.
40+
====
41+
42+
== Possible solutions
43+
44+
Consider if it is possible to implement the security model without using denied privileges.
45+
46+
For example, you can replace the generic grant from the <<example-scenario-22nd1, Example scenario>> with the following more fine-grained alternative:
47+
[source, cypher]
48+
----
49+
GRANT MATCH {*} ON GRAPH public-db, documentation-db NODES * TO role, otherrole
50+
----
51+
52+
53+
If a `DENY` is required, it must be set to a role that is directly assigned to users without using auth rules, to guarantee that it will always be applied.
54+
55+
ifndef::backend-pdf[]
56+
[discrete.glossary]
57+
== Glossary
58+
59+
include::partial$glossary.adoc[]
60+
endif::[]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
= 22ND2
2+
3+
== Status description
4+
error: data exception - operation not allowed for roles with `DENY` privileges. Invalid input: `'{ <<query>> }'` is not allowed for roles with `DENY` privileges.
5+
6+
== Explanation
7+
8+
If an auth rule fails to evaluate, for example, because it depends on a claim that the user's auth token does not contain, Neo4j will default to not assigning that role to the user.
9+
10+
11+
When a role contains denied privileges, not assigning the role actually removes the denies, which means the user ends up with more privileges than they should.
12+
To avoid this, roles cannot have both `DENY` privileges and be granted to an auth rule.
13+
14+
This exception is thrown when attempting to grant a role to an auth rule when the role has denied privileges.
15+
16+
[[example-scenario-22nd2]]
17+
== Example scenario
18+
19+
Given that a role has denied privileges:
20+
[source, cypher]
21+
----
22+
DENY MATCH {*} ON GRAPH secret-db NODES * TO role
23+
----
24+
25+
When attempting to assign the role to an auth rule:
26+
[source, cypher]
27+
----
28+
CYPHER 25 GRANT ROLE otherrole, role TO AUTH RULE authrule
29+
----
30+
31+
The following error will be thrown:
32+
[source]
33+
----
34+
error: data exception - operation not allowed for roles with DENY privileges. Invalid input: 'CYPHER 25 GRANT ROLE role TO AUTH RULE authrule' is not allowed for roles with `DENY` privileges.
35+
----
36+
37+
[NOTE]
38+
====
39+
The error message contains a subset of the original query that caused the issue.
40+
Since `otherrole` does not have denied privileges, it is not included.
41+
====
42+
43+
== Possible solutions
44+
45+
Consider whether it is possible to implement the security model without using denied privileges, for example, by revoking granted privileges or reducing the scope of the grant statements.
46+
47+
For example, you can replace the generic grant from the <<example-scenario-22nd2, Example scenario>> with the following more fine-grained alternative:
48+
[source, cypher]
49+
----
50+
GRANT MATCH {*} ON GRAPH public-db, documentation-db NODES * TO role, otherrole
51+
----
52+
53+
If a `DENY` is required, it must be set to a role that is directly assigned to users without using auth rules, to guarantee that it will always be applied.
54+
55+
ifndef::backend-pdf[]
56+
[discrete.glossary]
57+
== Glossary
58+
59+
include::partial$glossary.adoc[]
60+
endif::[]

modules/ROOT/pages/errors/gql-errors/index.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ Status description:: error: data exception - node element type in use. The node
706706

707707
Status description:: error: data exception - graph type constraint not supported. Graph type constraint definitions are not supported in the `{ <<graphTypeOperation>> }` operation.
708708

709+
=== xref:errors/gql-errors/22ND1.adoc[22ND1]
710+
711+
Status description:: error: data exception - operation not allowed for roles that are granted to an `AUTH RULE`. Invalid input: `'{ <<query>> }'` is not allowed for roles that are granted to an `AUTH RULE`.
712+
713+
=== xref:errors/gql-errors/22ND2.adoc[22ND2]
714+
715+
Status description:: error: data exception - operation not allowed for roles with `DENY` privileges. Invalid input: `'{ <<query>> }'` is not allowed for roles with `DENY` privileges.
716+
709717

710718
[[invalid-transaction-state]]
711719
== Invalid transaction state

0 commit comments

Comments
 (0)