Skip to content

Commit e54b57c

Browse files
committed
updating to include immutable roles
1 parent a67a1fc commit e54b57c

File tree

9 files changed

+167
-120
lines changed

9 files changed

+167
-120
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
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[]
187+
*** xref:authentication-authorization/privileges-and-roles-immutable.adoc[]
188188
*** xref:authentication-authorization/manage-execute-permissions.adoc[]
189189
** xref:authentication-authorization/built-in-roles.adoc[]
190190
** Integration with auth systems
@@ -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/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/privileges-and-roles-immutable.adoc[].
3131

3232
* _database-privilege_
3333
** `ACCESS` - allows access to a specific database or remote database alias.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ 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. 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-and-roles-immutable.adoc[].
4949

5050
* _graph-privilege_:
5151
** 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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 @@ 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. You can optionally use `SHOW ROLES YIELD *` to return the `IMMUTABLE` column. (See xref:authentication-authorization/manage-roles.adoc#access-control-immutable-roles[immutable roles] for more information).
343343

344344
.`SHOW ROLES` output
345345
[options="header", width="100%", cols="2a,4,2m"]
@@ -351,6 +351,10 @@ You can view all available roles using the Cypher command `SHOW ROLES`, which re
351351
| role
352352
| Role name
353353
| STRING
354+
355+
| immutable
356+
| Whether the role is immutable
357+
| BOOLEAN
354358
|===
355359

356360
.List all roles
@@ -481,18 +485,18 @@ It is also possible to use `SKIP` and `LIMIT` to paginate the results.
481485
[[access-control-create-roles]]
482486
== Creating roles
483487

484-
Roles can be created using `CREATE ROLE`:
488+
Roles can be created using `CREATE [IMMUTABLE] ROLE`:
485489

486490
[source, syntax]
487491
----
488-
CREATE ROLE name [IF NOT EXISTS] [AS COPY OF otherName]
492+
CREATE [IMMUTABLE] ROLE name [IF NOT EXISTS] [AS COPY OF otherName]
489493
----
490494

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

493497
[source, syntax]
494498
----
495-
CREATE OR REPLACE ROLE name [AS COPY OF otherName]
499+
CREATE OR REPLACE [IMMUTABLE] ROLE name [AS COPY OF otherName]
496500
----
497501

498502
[NOTE]
@@ -504,7 +508,7 @@ The following naming rules apply:
504508
* Role names are case sensitive.
505509
====
506510

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

509513
.Copy a role
510514
======
@@ -576,6 +580,11 @@ This is equivalent to running `DROP ROLE myrole IF EXISTS` followed by `CREATE R
576580
* The `CREATE OR REPLACE ROLE` command does not allow you to use the `IF NOT EXISTS`.
577581
====
578582

583+
[[access-control-immutable-roles]]
584+
=== Immutable roles
585+
Immutable roles are roles which cannot be modified in the usual way after they have been created. This means they cannot be renamed, dropped, or have privileges granted to or revoked from them. See xref:authentication-authorization/privileges-and-roles-immutable.adoc[here] for details.
586+
587+
They are useful in cases where you need a permanent built-in system role which cannot be modified even by users who have xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[ROLE MANAGEMENT privileges].
579588

580589
[[access-control-rename-roles]]
581590
== Renaming roles
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
[role=label--new-5.24]
2+
[role=enterprise-edition not-on-aura]
3+
[[access-control-privileges-immutable]]
4+
= Immutable privileges and roles
5+
:description: This section explains how to use Cypher to manage immutable privileges and roles.
6+
7+
[NOTE]
8+
====
9+
Immutable roles are newly introduced in Neo4j 5.24. Immutable privileges have been available since Neo4j 5.0.
10+
====
11+
12+
[[access-control-privileges-immutable-admin]]
13+
== How to administer immutable privileges and roles
14+
15+
Unlike for regular privileges and roles, immutable privileges and roles cannot be administered by users with xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-privilege-management[PRIVILEGE MANAGEMENT] and xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[ROLE MANAGEMENT] privileges. Instead, they can only be administered when auth is disabled -- that is, when the configuration setting <<config_dbms.security.auth_enabled,`dbms.security.auth_enabled`>> is set to `false`.
16+
17+
[CAUTION]
18+
It is intended that administering immutable privileges and roles is an extraordinarily rare scenario and one which should be undertaken with extreme caution (i.e. when the dbms has been isolated by some other means and unauthorized access can be reliably prevented). It is considered to be the kind of action which may be performed once during the commissioning phase of a database.
19+
20+
When the configuration setting <<config_dbms.security.auth_enabled,`dbms.security.auth_enabled`>> is set to `false`, immutable privileges and roles can be administered in a similar way to regular privileges and roles, using the `IMMUTABLE` keyword.
21+
22+
Once the dbms is safely isolated from external connections, follow these steps to administer immutable privileges and roles:
23+
24+
. Change the config setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] to `false`.
25+
. Restart the DBMS.
26+
. Create or remove immutable privileges and roles in the same way as regular privileges and roles but with the addition of the `IMMUTABLE` keyword
27+
(see xref:authentication-authorization/privileges-and-roles-immutable.adoc#access-control-privileges-immutable-usecase[here] for examples).
28+
. Change the config setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] back to `true`.
29+
. Restart the DBMS.
30+
31+
Privileges and roles created in this way will now appear to all users as an immutable part of the DBMS.
32+
The only way to subsequently change or remove them it would be to repeat the process of setting xref:configuration/configuration-settings.adoc#config_dbms.security.auth_enabled[`dbms.security.auth_enabled`] to `false`.
33+
34+
35+
[[access-control-privileges-immutable-usecase]]
36+
== When to use immutable privileges and roles
37+
38+
Immutable privileges and roles are useful for restricting the actions of users who can themselves xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-privilege-management[administer privileges] and xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-role-management[roles].
39+
40+
=== Immutable privileges
41+
42+
You may want to prevent all users from performing Database Management, even the `admin` user (who are themselves able to add or remove privileges).
43+
To do so, it would not be adequate to run:
44+
45+
[source, cypher]
46+
----
47+
DENY DATABASE MANAGEMENT ON DBMS TO PUBLIC
48+
----
49+
50+
This is because the `admin` user could subsequently runs this:
51+
52+
[source, cypher]
53+
----
54+
REVOKE DENY DATABASE MANAGEMENT ON DBMS FROM PUBLIC
55+
----
56+
57+
They would then effectively regain Database Management privileges.
58+
59+
Instead, you could use an immutable privilege.
60+
61+
.Create an immutable privilege
62+
======
63+
64+
[source, cypher, role=test-skip]
65+
----
66+
DENY IMMUTABLE DATABASE MANAGEMENT ON DBMS TO PUBLIC
67+
----
68+
[source, cypher, role=noplay]
69+
----
70+
SHOW PRIVILEGES WHERE IMMUTABLE
71+
----
72+
.Result
73+
[options="header,footer", width="100%", cols="m,m,m,m,m,m,m"]
74+
|===
75+
|access
76+
|action
77+
|resource
78+
|graph
79+
|segment
80+
|role
81+
|immutable
82+
83+
|"DENIED"
84+
|"database_management"
85+
|"database"
86+
|"*"
87+
|"database"
88+
|"PUBLIC"
89+
|true
90+
91+
7+a|Rows: 1
92+
|===
93+
94+
======
95+
96+
=== Immutable roles
97+
98+
Immutable _privileges_ are useful when wanting to attach a permanent privilege to the `PUBLIC` role, which will apply to all users (because the `PUBLIC` role applies to all users).
99+
100+
If you want permanent privileges, but with more control over which users they apply to, then you need to use immutable roles in conjunction with immutable privileges.
101+
102+
For example you have a user called `alice` who also has `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges, but you want to prevent them from dropping any databases (and you want to prevent them from being able to simple remove this restriction using their `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges).
103+
104+
.Create an immutable role
105+
======
106+
107+
Create an immutable role to hold the immutable privileges
108+
[source, cypher, role=noplay]
109+
----
110+
CREATE IMMUTABLE ROLE restrictedAdmin
111+
----
112+
Immutably deny the `DROP DATABASE` privilege.
113+
[source, cypher, role=noplay]
114+
----
115+
DENY IMMUTABLE DROP DATABASE ON DBMS TO restrictedAdmin
116+
----
117+
Grant the restrictedAdmin role to alice to prevent her dropping databases.
118+
[source, cypher, role=noplay]
119+
----
120+
GRANT restrictedAdmin TO alice
121+
----
122+
Now (despite having `ROLE MANAGEMENT` and `PRIVILEGE MANAGEMENT` privileges) alice will not be able do any of the following:
123+
[source, cypher, role=noplay]
124+
----
125+
DROP DATABASE foo
126+
----
127+
[source, cypher, role=noplay]
128+
----
129+
REVOKE ROLE restrictedAdmin FROM alice
130+
----
131+
[source, cypher, role=noplay]
132+
----
133+
DROP ROLE restrictedAdmin
134+
----
135+
[source, cypher, role=noplay]
136+
----
137+
REVOKE DENY DROP DATABASE ON DBMS FROM restrictedAdmin
138+
----
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. This is to make sure that the role and all of its privileges is explicitly and completely immutable.
144+
====
145+
146+
147+

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ You can find more information in the xref:tools/cypher-shell.adoc[Cypher Shell s
8282
+
8383
Immutable privileges are useful for restricting the actions of users who themselves are able to administer privileges. +
8484
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.
85+
You can find more information xref:authentication-authorization/privileges-and-roles-immutable.adoc[here] on how to administer immutable privileges.
8686

8787
* Changes to Neo4j indexes
8888
** 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.

modules/ROOT/pages/tutorial/tutorial-immutable-privileges.adoc

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

0 commit comments

Comments
 (0)