Skip to content

Commit f07e88b

Browse files
HannesSandbergphil198renetapopova
authored
Example of property-based access control using temporal value (#1887)
cypher manual [PR](neo4j/docs-cypher#1070) --------- Co-authored-by: Phil Wright <[email protected]> Co-authored-by: Reneta Popova <[email protected]>
1 parent 79daab1 commit f07e88b

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

modules/ROOT/pages/authentication-authorization/property-based-access-control.adoc

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,33 @@ The role `regularUsers` does not need to have `READ` privilege for the property
9797
[source, syntax, role="noheader"]
9898
----
9999
DENY READ {*} ON GRAPH * FOR (n) WHERE NOT n.classification IN ['UNCLASSIFIED', 'PUBLIC'] TO regularUsers
100-
----
100+
----
101+
102+
.Granting permission to `READ` all properties on nodes where the property `createdAt` is later than the current date to role `regularUsers`:
103+
[source, syntax, role="noheader"]
104+
----
105+
GRANT READ {*} ON GRAPH * FOR (n) WHERE n.createdAt > date() TO regularUsers
106+
----
107+
[NOTE]
108+
====
109+
The `date()` function is evaluated, and the value used to evaluate the privilege is the date when the property-based privilege is created.
110+
Keep this in mind when designing your property rules, and use the `SHOW PRIVILEGES AS COMMANDS` command to check the stored value.
111+
This is essential when revoking property-based privileges containing evaluated function values like `date()`.
112+
====
113+
[NOTE]
114+
====
115+
Not all temporal values are comparable, see link:{neo4j-docs-base-uri}/cypher-manual/{page-version}/syntax/operators/#cypher-ordering[Cypher Manual -> Syntax -> Operators -> Ordering and comparison of values].
116+
====
117+
118+
.Show the privilege created by the command in the previous example as a revoke command:
119+
[source, syntax, role="noheader"]
120+
----
121+
SHOW ROLE regularUsers PRIVILEGES AS REVOKE COMMANDS
122+
----
123+
.Result
124+
[options="header,footer", width="100%", cols="m"]
125+
|===
126+
|command
127+
|"REVOKE GRANT READ {*} ON GRAPH * FOR (n) WHERE n.createdAt > date('2024-10-25') FROM `regularUsers`"
128+
a|Rows: 1
129+
|===

0 commit comments

Comments
 (0)