Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,33 @@ The role `regularUsers` does not need to have `READ` privilege for the property
[source, syntax, role="noheader"]
----
DENY READ {*} ON GRAPH * FOR (n) WHERE NOT n.classification IN ['UNCLASSIFIED', 'PUBLIC'] TO regularUsers
----
----

.Granting permission to `READ` all properties on nodes where the property `createdAt` is later than the current date to role `regularUsers`:
[source, syntax, role="noheader"]
----
GRANT READ {*} ON GRAPH * FOR (n) WHERE n.createdAt > date() TO regularUsers
----
[NOTE]
====
The `date()` function is evaluated, and the value used to evaluate the privilege is the date when the property-based privilege is created.
Keep this in mind when designing your property rules, and use the `SHOW PRIVILEGES AS COMMANDS` command to check the stored value.
This is essential when revoking property-based privileges containing evaluated function values like `date()`.
====
[NOTE]
====
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].
====

.Show the privilege created by the command in the previous example as a revoke command:
[source, syntax, role="noheader"]
----
SHOW ROLE regularUsers PRIVILEGES AS REVOKE COMMANDS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a lot of things granted to that role but if this page isn't being tested I guess just returning the one you want to show is fine 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I did want to show the explicit case and not everything that was granted to the role

----
.Result
[options="header,footer", width="100%", cols="m"]
|===
|command
|"REVOKE GRANT READ {*} ON GRAPH * FOR (n) WHERE n.createdAt > date('2024-10-25') FROM `regularUsers`"
a|Rows: 1
|===