Skip to content

Commit 4120c22

Browse files
committed
Document immutable roles
1 parent a23e6bb commit 4120c22

File tree

10 files changed

+183
-125
lines changed

10 files changed

+183
-125
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,9 @@
184184
*** xref:authentication-authorization/dbms-administration.adoc[]
185185
*** xref:authentication-authorization/load-privileges.adoc[]
186186
*** xref:authentication-authorization/limitations.adoc[]
187-
*** xref:authentication-authorization/privileges-immutable.adoc[]
188187
*** xref:authentication-authorization/manage-execute-permissions.adoc[]
189188
** xref:authentication-authorization/built-in-roles.adoc[]
189+
** xref:authentication-authorization/immutable-roles-privileges.adoc[]
190190
** Integration with auth systems
191191
*** xref:authentication-authorization/auth-providers.adoc[]
192192
*** xref:authentication-authorization/ldap-integration.adoc[]
@@ -246,7 +246,6 @@
246246
** xref:tutorial/tutorial-composite-database.adoc[]
247247
** xref:tutorial/access-control.adoc[]
248248
** xref:tutorial/tutorial-sso-configuration.adoc[]
249-
** xref:tutorial/tutorial-immutable-privileges.adoc[]
250249
** xref:tutorial/tutorial-clustering-docker.adoc[]
251250
252251
// ** xref:clustering-advanced/index.adoc[]

modules/ROOT/images/privileges_grant_and_deny_syntax.svg

Lines changed: 1 addition & 1 deletion
Loading

modules/ROOT/pages/authentication-authorization/database-administration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The components of the database privilege commands are:
2727
* _mutability_:
2828
** `IMMUTABLE` - When used in conjunction with `GRANT` or `DENY`, specifies that a privilege cannot subsequently be removed unless auth is disabled.
2929
Contrastingly, when `IMMUTABLE` is specified in conjunction with a `REVOKE` command, it will act as a filter and only remove matching _immutable_ privileges.
30-
See also xref:authentication-authorization/privileges-immutable.adoc[].
30+
See also xref:authentication-authorization/immutable-roles-privileges.adoc[].
3131

3232
* _database-privilege_
3333
** `ACCESS` - allows access to a specific database or remote database alias.
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
[role=enterprise-edition not-on-aura]
2+
[[immutable-roles-and-privileges]]
3+
= Immutable roles and privileges
4+
:description: This section explains how to use Cypher to manage immutable roles and privileges.
5+
6+
[NOTE]
7+
====
8+
Immutable roles are available starting with Neo4j 5.26.
9+
====
10+
11+
Immutable privileges and roles are useful for restricting the actions of users who can themselves administer xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[roles] xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-privilege-management[privileges].
12+
13+
14+
[CAUTION]
15+
====
16+
Immutable privileges and roles should only be used in situations where changes are rare.
17+
They are intentionally difficult to modify, so changes should be undertaken with caution (e.g., when the DBMS has been isolated by some other means and unauthorized access can be reliably prevented).
18+
Typically, this type of modification should only be made once during the commissioning phase of a DBMS.
19+
====
20+
21+
[[administer-immutable-roles-and-privileges]]
22+
== Administer immutable roles and privileges
23+
24+
After the DBMS is safely isolated from external connections, follow these steps to administer immutable roles and privileges:
25+
26+
. Change the config setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] to `false`.
27+
. Restart the DBMS.
28+
. Create or remove immutable privileges and roles in the same way as regular privileges and roles but with the addition of the `IMMUTABLE` keyword.
29+
See <<immutable-roles-privileges-examples, Examples>>.
30+
. Change the config setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] back to `true`.
31+
. Restart the DBMS.
32+
33+
Privileges and roles created in this way can now appear to all users as an immutable part of the DBMS.
34+
If you want to change or remove them, you must repeat the process of setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] to `false`.
35+
36+
[[immutable-roles-privileges-examples]]
37+
== Examples
38+
39+
The following examples demonstrate how to use Cypher to manage immutable roles and privileges.
40+
41+
=== Restricting the actions of users who can manage privileges
42+
43+
To prevent all users, including the `admin` user, from performing *database management*, follow these steps:
44+
45+
. Ensure that you have completed steps 1 an 2 from <<administer-immutable-roles-and-privileges>>.
46+
. Run the following command to deny the `IMMUTABLE DATABASE MANAGEMENT` privilege to the `PUBLIC` role:
47+
+
48+
[source, cypher, role=test-skip]
49+
----
50+
DENY IMMUTABLE DATABASE MANAGEMENT ON DBMS TO PUBLIC
51+
----
52+
53+
. Verify that the `IMMUTABLE` keyword has been added to the privilege:
54+
+
55+
[source, cypher, role=noplay]
56+
----
57+
SHOW PRIVILEGES WHERE IMMUTABLE
58+
----
59+
+
60+
.Result
61+
[options="header,footer", width="100%", cols="1m,2m,1m,1m,1m,1m,1m"]
62+
|===
63+
|access
64+
|action
65+
|resource
66+
|graph
67+
|segment
68+
|role
69+
|immutable
70+
71+
|"DENIED"
72+
|"database_management"
73+
|"database"
74+
|"*"
75+
|"database"
76+
|"PUBLIC"
77+
|true
78+
79+
7+a|Rows: 2
80+
|===
81+
+
82+
The result shows that all users are restricted from adding or removing privileges, including the `admin` user.
83+
. Ensure you have completed steps 4 and 5 from <<administer-immutable-roles-and-privileges>>.
84+
85+
=== Restricting the actions of users who can manage roles and privileges
86+
87+
If you want permanent privileges but with more control over which users they apply to, you need to use immutable roles with immutable privileges.
88+
For example, you have a user called `alice` who has `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges.
89+
To prevent `alice` from dropping any databases and from being able to remove this restriction using their `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges, follow these steps:
90+
91+
. Ensure that you have completed steps 1 an 2 from <<administer-immutable-roles-and-privileges>>.
92+
. Create an immutable role to hold the immutable privileges:
93+
+
94+
[source, cypher, role=noplay]
95+
----
96+
CREATE IMMUTABLE ROLE restrictedAdmin
97+
----
98+
99+
. Immutably deny the `DROP DATABASE` privilege:
100+
+
101+
[source, cypher, role=noplay]
102+
----
103+
DENY IMMUTABLE DROP DATABASE ON DBMS TO restrictedAdmin
104+
----
105+
106+
. Grant the restrictedAdmin role to `alice` to prevent her dropping databases:
107+
+
108+
[source, cypher, role=noplay]
109+
----
110+
GRANT restrictedAdmin TO alice
111+
----
112+
+
113+
. Ensure you have completed steps 4 and 5 from <<administer-immutable-roles-and-privileges>>.
114+
+
115+
Now, despite having `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges, `alice` will not be able do any of the following:
116+
+
117+
.Drop databases:
118+
[source, cypher, role=noplay]
119+
----
120+
DROP DATABASE foo
121+
----
122+
+
123+
.Remove the restrictedAdmin role from `alice`
124+
[source, cypher, role=noplay]
125+
----
126+
REVOKE ROLE restrictedAdmin FROM alice
127+
----
128+
+
129+
.Remove the `DROP DATABASE` privilege from the restrictedAdmin role
130+
[source, cypher, role=noplay]
131+
----
132+
DROP ROLE restrictedAdmin
133+
----
134+
+
135+
.Remove `DENY DROP DATABASE` from the restrictedAdmin role
136+
[source, cypher, role=noplay]
137+
----
138+
REVOKE DENY DROP DATABASE ON DBMS FROM restrictedAdmin
139+
----
140+
141+
[NOTE]
142+
====
143+
Only immutable privileges (e.g. `DENY IMMUTABLE DROP DATABASE` in the example above) can be assigned to immutable roles.
144+
This is to make sure that the role and all of its privileges is explicitly and completely immutable.
145+
====
146+

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ The components of the graph privilege commands are:
4545
** `REVOKE` – removes granted or denied privileges from roles.
4646

4747
* _mutability_:
48-
** `IMMUTABLE` can optionally be specified when performing a `GRANT` or `DENY` to indicate that the privilege cannot be subsequently removed unless auth is disabled. Auth must also be disabled in order to `GRANT` or `DENY` an immutable privilege. Contrastingly, when `IMMUTABLE` is specified in conjunction with a `REVOKE` command, it will act as a filter and only remove matching _immutable_ privileges. See also xref:authentication-authorization/privileges-immutable.adoc[].
48+
** `IMMUTABLE` can optionally be specified when performing a `GRANT` or `DENY` to indicate that the privilege cannot be subsequently removed unless auth is disabled.
49+
Auth must also be disabled in order to `GRANT` or `DENY` an immutable privilege.
50+
Contrastingly, when `IMMUTABLE` is specified in conjunction with a `REVOKE` command, it will act as a filter and only remove matching _immutable_ privileges.
51+
Starting from Neo4j 5.26, immutable privileges can also be used together with immutable roles.
52+
See xref:authentication-authorization/immutable-roles-privileges.adoc[] for more information.
4953

5054
* _graph-privilege_:
5155
** Can be either a xref:authentication-authorization/privileges-reads.adoc[read privilege] or xref:authentication-authorization/privileges-writes.adoc[write privilege].

modules/ROOT/pages/authentication-authorization/manage-roles.adoc

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ GRANT SHOW ROLE
6262
----
6363

6464

65-
(see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[DBMS ROLE MANAGEMENT privileges]).
65+
See xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[DBMS ROLE MANAGEMENT privileges].
6666
|===
6767

6868

@@ -140,7 +140,7 @@ a|
140140
GRANT SHOW PRIVILEGE
141141
----
142142

143-
(see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-privilege-management[DBMS PRIVILEGE MANAGEMENT privileges])
143+
See xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-privilege-management[DBMS PRIVILEGE MANAGEMENT privileges].
144144

145145
|===
146146

@@ -150,7 +150,7 @@ GRANT SHOW PRIVILEGE
150150

151151

152152
| Command
153-
m| CREATE ROLE
153+
m| CREATE [IMMUTABLE] ROLE
154154

155155
| Syntax
156156
a|
@@ -339,7 +339,9 @@ For more information, see xref:authentication-authorization/dbms-administration.
339339
== Listing roles
340340

341341

342-
You can view all available roles using the Cypher command `SHOW ROLES`, which returns a single column.
342+
You can view all available roles using the Cypher command `SHOW ROLES`, which returns a single column by default.
343+
Starting from 5.26, you can optionally use `SHOW ROLES YIELD *` to see if the role is immutable.
344+
See <<access-control-immutable-roles, Immutable roles>> for more information.
343345

344346
.`SHOW ROLES` output
345347
[options="header", width="100%", cols="2a,4,2m"]
@@ -351,6 +353,10 @@ You can view all available roles using the Cypher command `SHOW ROLES`, which re
351353
| role
352354
| Role name
353355
| STRING
356+
357+
| immutable
358+
| `true` if the role is immutable, otherwise `false`.
359+
| BOOLEAN
354360
|===
355361

356362
.List all roles
@@ -481,18 +487,18 @@ It is also possible to use `SKIP` and `LIMIT` to paginate the results.
481487
[[access-control-create-roles]]
482488
== Creating roles
483489

484-
Roles can be created using `CREATE ROLE`:
490+
Roles can be created using `CREATE [IMMUTABLE] ROLE`:
485491

486492
[source, syntax]
487493
----
488-
CREATE ROLE name [IF NOT EXISTS] [AS COPY OF otherName]
494+
CREATE [IMMUTABLE] ROLE name [IF NOT EXISTS] [AS COPY OF otherName]
489495
----
490496

491-
Roles can be created or replaced by using `CREATE OR REPLACE ROLE`:
497+
Roles can be created or replaced by using `CREATE OR REPLACE [IMMUTABLE] ROLE`:
492498

493499
[source, syntax]
494500
----
495-
CREATE OR REPLACE ROLE name [AS COPY OF otherName]
501+
CREATE OR REPLACE [IMMUTABLE] ROLE name [AS COPY OF otherName]
496502
----
497503

498504
[NOTE]
@@ -504,7 +510,7 @@ The following naming rules apply:
504510
* Role names are case sensitive.
505511
====
506512

507-
A role can be copied, keeping its privileges, using `CREATE ROLE name AS COPY OF otherName`.
513+
A role can be copied, keeping its privileges, using `CREATE [IMMUTABLE] ROLE name AS COPY OF otherName`.
508514

509515
.Copy a role
510516
======
@@ -573,9 +579,19 @@ This is equivalent to running `DROP ROLE myrole IF EXISTS` followed by `CREATE R
573579

574580
[NOTE]
575581
====
576-
* The `CREATE OR REPLACE ROLE` command does not allow you to use the `IF NOT EXISTS`.
582+
The `CREATE OR REPLACE ROLE` command does not allow you to use the `IF NOT EXISTS`.
577583
====
578584

585+
[role=new-in-5.26]
586+
[[access-control-immutable-roles]]
587+
== Immutable roles
588+
589+
Immutable roles are those that cannot be modified in the usual way.
590+
This means they cannot be created, renamed, dropped, or have privileges granted to or revoked from them.
591+
See xref:authentication-authorization/immutable-roles-privileges.adoc[Immutable roles and privileges] for details.
592+
593+
They are useful in cases where you need a permanent built-in system role that cannot be modified even by users who have xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[`ROLE MANAGEMENT` privileges].
594+
579595

580596
[[access-control-rename-roles]]
581597
== Renaming roles

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

Lines changed: 0 additions & 46 deletions
This file was deleted.

modules/ROOT/pages/index.adoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ You can find more information in the xref:tools/cypher-shell.adoc[Cypher Shell s
8080

8181
* Immutable privileges.
8282
+
83-
Immutable privileges are useful for restricting the actions of users who themselves are able to administer privileges. +
83+
Immutable privileges are useful for restricting the actions of users who themselves are able to administer privileges.
84+
Starting with Neo4j 5.26, immutable roles are also vailable. +
8485
Cloud operators can use sidecar design pattern to control RBAC-based permissions. +
85-
You can find xref:tutorial/tutorial-immutable-privileges.adoc[a tutorial] on how to administer immutable privileges.
86+
For more information, see xref:authentication-authorization/immutable-roles-privileges.adoc[Immutable roles and privileges].
8687

8788
* Changes to Neo4j indexes
8889
** The B-tree index type has been removed.

modules/ROOT/pages/tutorial/index.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ The following step-by-step tutorials cover common operational tasks or otherwise
1111
* xref:tutorial/tutorial-composite-database.adoc[Set up and use a Composite database] -- This tutorial walks through the basics of setting up and using Composite databases.
1212
* xref:tutorial/access-control.adoc[Fine-grained access control (example)] -- This tutorial presents an example that illustrates various aspects of security and fine-grained access control.
1313
* xref:tutorial/tutorial-sso-configuration.adoc[Configuring Neo4j Single Sign-On (SSO)] -- This tutorial presents examples and solutions to common problems when configuring SSO.
14-
* xref:tutorial/tutorial-immutable-privileges.adoc[Administering immutable privileges] -- This tutorial describes methods for administering immutable privileges.
1514
* xref:tutorial/tutorial-clustering-docker.adoc[Deploy a Neo4j cluster in a Docker container] -- This tutorial walks through setting up a Neo4j cluster on your local computer for testing purposes.

0 commit comments

Comments
 (0)