Skip to content

Commit f07ae43

Browse files
docs: updated and added OIDC credential forwarding
1 parent 803de95 commit f07ae43

File tree

2 files changed

+195
-24
lines changed

2 files changed

+195
-24
lines changed

modules/ROOT/pages/database-administration/aliases/manage-aliases-standard-databases.adoc

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,18 +379,25 @@ SHOW ALIAS `northwind-2022` FOR DATABASE YIELD name, properties
379379
[[alias-management-create-remote-database-alias]]
380380
=== Create database aliases for remote databases
381381

382-
A database alias can target a remote database by providing an URL and the credentials of a user on the remote Neo4j DBMS.
382+
A database alias can target a remote database by providing a URL and the credentials of a user on the remote Neo4j DBMS.
383383
See xref:database-administration/aliases/remote-database-alias-configuration.adoc[] for the necessary configurations.
384384

385385
Since remote database aliases target databases that are not in this DBMS, they do not fetch the default Cypher version from their target like the local database aliases.
386386
Instead, they are assigned the version given by xref:configuration/configuration-settings.adoc#config_db.query.default_language[`db.query.default_language`], which is set in the `neo4j.conf` file.
387387
Alternatively, you can specify the version in the `CREATE ALIAS` or `ALTER ALIAS` commands.
388388
See xref:database-administration/aliases/manage-aliases-standard-databases.adoc#set-default-language-for-remote-database-aliases[] and xref:database-administration/aliases/manage-aliases-standard-databases.adoc#alter-default-language-remote-database-alias[] for more information.
389389

390+
When creating a remote database alias, the credentials used to target to the remote DBMS need to be specified and can be either:
391+
392+
* `STORED NATIVE CREDENTIALS`, using the credentials of a single native user on the remote DBMS.
393+
* `OIDC CREDENTIAL FORWARDING`, forwarding the bearer authentication token from the logged-in user on the local DBMS. The user needs to be logged in with an identity provider supporting OIDC. label:new[Introduced in 2025.10]
394+
395+
To use the credentials of a native user on the remote DBMS, `USER` and `PASSWORD` need to be set when creating the alias.
396+
390397
.Query
391398
[source, cypher]
392399
----
393-
CREATE ALIAS `remote-northwind` FOR DATABASE `northwind-graph-2020`
400+
CREATE ALIAS `remote-northwind-stored-credentials` FOR DATABASE `northwind-graph-2020`
394401
AT "neo4j+s://location:7687"
395402
USER alice
396403
PASSWORD 'example_secret'
@@ -401,20 +408,51 @@ To view the remote database alias details, use the `SHOW ALIASES FOR DATABASE` c
401408
.Query
402409
[source, cypher]
403410
----
404-
SHOW ALIAS `remote-northwind`
411+
SHOW ALIAS `remote-northwind-stored-credentials`
405412
FOR DATABASE
406413
----
407414

408415
.Result
409416
[role="queryresult"]
410417
----
411-
+----------------------------------------------------------------------------------------------------------+
412-
| name | composite | database | location | url | user |
413-
+----------------------------------------------------------------------------------------------------------+
414-
| "remote-northwind" | NULL | "northwind-graph-2020" | "remote" | "neo4j+s://location:7687" | "alice" |
415-
+----------------------------------------------------------------------------------------------------------+
418+
+-----------------------------------------------------------------------------------------------------------------------------+
419+
| name | composite | database | location | url | user |
420+
+-----------------------------------------------------------------------------------------------------------------------------+
421+
| "remote-northwind-stored-credentilas" | NULL | "northwind-graph-2020" | "remote" | "neo4j+s://location:7687" | "alice" |
422+
+-----------------------------------------------------------------------------------------------------------------------------+
423+
----
424+
425+
The `OIDC CREDENTIAL FORWARDING` clause is used to configure a remote database alias to use the logged-in user's OIDC credentials to authenticate to the remote DBMS.
426+
In order to use this method to authenticate, the local DBMS and remote DBMS needs to have SSO authentication and authorization through identity providers implementing the OIDC standard configured, see the xref:authentication-authorization/sso-integration.adoc[SSO integration] on how to configure OIDC identity providers.
427+
428+
.Query
429+
[source, cypher]
430+
----
431+
CREATE ALIAS `remote-northwind-oidc-credential-forwarding` FOR DATABASE `northwind-graph-2020`
432+
AT "neo4j+s://location:7687"
433+
OIDC CREDENTIAL FORWARDING
416434
----
417435

436+
Since the alias use the credentials of the logged-in user when targeting the remote DBMS, there are no stored credentials and user will be `NULL`.
437+
438+
.Query
439+
[source, cypher]
440+
----
441+
SHOW ALIAS `remote-northwind-oidc-credential-forwarding`
442+
FOR DATABASE
443+
----
444+
445+
.Result
446+
[role="queryresult"]
447+
----
448+
+-------------------------------------------------------------------------------------------------------------------------------------+
449+
| name | composite | database | location | url | user |
450+
+-------------------------------------------------------------------------------------------------------------------------------------+
451+
| "remote-northwind-oidc-credential-forwarding" | NULL | "northwind-graph-2020" | "remote" | "neo4j+s://location:7687" | NULL |
452+
+-------------------------------------------------------------------------------------------------------------------------------------+
453+
----
454+
455+
418456
You can also use `IF EXISTS` or `OR REPLACE` when creating remote database aliases.
419457
It works the same way as described in the <<_use_if_exists_or_or_replace_when_creating_database_aliases, Use `IF EXISTS` or `OR REPLACE` when creating database aliases>> section.
420458
Both check for any remote or local database aliases (with `IF NOT EXISTS` also checking for databases).

modules/ROOT/pages/database-administration/aliases/remote-database-alias-configuration.adoc

Lines changed: 149 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,46 @@ The following steps describe the setup required to define a remote database alia
1414
They are also useful should there be any changes in the name of the databases or the location of standalone servers and cluster instances.
1515
Additionally, you will also find information here on best practices and additional guidance on any changes in the configuration.
1616

17-
== Setup example
18-
19-
In this example, _Alice_ is an administrator and _Carol_ is a user who needs access to a database managed by _Bob_:
20-
21-
image::remote-alias-overview.svg[title="Overview of the required remote database alias setup", role="middle"]
22-
2317
A remote alias defines:
2418

2519
* Which user of the remote **DBMS B** is used.
2620
* Where the remote database is located.
2721
* How to connect to the remote database using driver settings.
2822
23+
When creating the remote database alias, it can be configured to authenticate with either:
24+
25+
* `STORED NATIVE CREDENTIALS`, the credentials of a single native user on the remote **DBMS B**.
26+
* `OIDC CREDENTIAL FORWARDING`, forwarding the bearer authentication token from the logged-in user on the local **DBMS A**. The user needs to be logged in with an identity provider supporting OIDC. label:new[Introduced in 2025.10]
27+
28+
29+
[[setup-example-stored-native-credentials]]
30+
== Setup example with stored native credentials
31+
32+
In this example, _Alice_ is an administrator and _Carol_ is a user who needs access to a database managed by _Bob_:
33+
34+
image::remote-alias-overview.svg[title="Overview of the required remote database alias setup when using stored credentials", role="middle"]
35+
36+
2937
[NOTE]
3038
====
3139
A remote database alias is only accessible to users with appropriate privileges.
3240
In the example above, _Bob_ is the administrator responsible for deciding which databases (`Db1` or `Db2`) the remote aliases can write and/or read.
3341
Meanwhile, _Alice_ is the administrator that assigns who has access to the privileges set by _Bob_.
3442
In the example, _Alice_ will assign that access to _Carol_.
3543
36-
See lxref:authentication-authorization/dbms-administration.adoc[DBMS privileges] for more information.
44+
See xref:authentication-authorization/dbms-administration.adoc[DBMS privileges] for more information.
3745
====
3846

3947
_Carol_ can use her own regular credentials to access the remote database `Db1` in DBMS after _Alice_ assigns this privilege to her user profile.
4048
This configuration will also allow _Carol_ to access `Db2` in **DBMS B**.
4149
If the administrators decide this should not be the case, then _Bob_ must define the appropriate privileges (see xref:authentication-authorization/index.adoc[Authentication and authorization] for further information).
4250

43-
== Configure a remote DBMS (_Bob_)
51+
=== Configure a remote DBMS (_Bob_)
4452

4553
In the suggested example, there are two administrators: _Alice_ and _Bob_.
4654
_Bob_ is the administrator responsible for the setup of the remote DBMS, which includes the following steps:
4755

4856
. Create the user profile to share with _Alice_.
49-
Currently, only user and password-based authentication (e.g. native authentication) are supported.
5057
. Define the permissions for the user. If you don’t want this user to access `Db2`, here is where you set it.
5158
. Securely transmit the credentials to _Alice_, setting up the link to database `Db1`.
5259
It is recommended to create a custom role to track all users shared on a remote connection, so that they remain trackable.
@@ -79,7 +86,7 @@ server.bolt.tls_level=REQUIRED
7986
----
8087

8188
[[remote-alias-config-DBMS_admin-A]]
82-
== Configure a DBMS with a remote database alias (_Alice_)
89+
=== Configure a DBMS with a remote database alias (_Alice_)
8390

8491
As _Alice_, you need to generate an encryption key.
8592
In this case, the credentials of a user of **DBMS B** are reversibly encrypted and stored in the system database of **DBMS A**.
@@ -145,7 +152,7 @@ chmod 640 conf/neo4j.conf
145152
bin/neo4j start --expand-commands
146153
----
147154

148-
== Manage remote database aliases
155+
=== Manage remote database aliases
149156

150157
You can use the xref:database-administration/aliases/manage-aliases-standard-databases.adoc[alias commands] to manage remote database aliases.
151158
In this case, it is strongly recommended to connect to a remote database alias with a secured connection.
@@ -154,15 +161,15 @@ Please note that only client-side SSL is supported.
154161
By default, remote aliases require a secured URI scheme such as `neo4j+s`.
155162
This can be disabled by setting the driver setting `ssl_enforced` to `false`.
156163

157-
For example, the following command can be used to create a remote database alias:
164+
For example, the following command can be used to create a remote database alias with stored native credentials:
158165

159166
[source, Cypher]
160167
----
161168
CREATE ALIAS `remote-neo4j` FOR DATABASE `neo4j` AT "neo4j+s://location:7687" USER alice PASSWORD 'secretpassword'
162169
----
163170

164-
In order to do so, either lxref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-database-management[database management]
165-
or lxref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[alias management] privileges are required.
171+
In order to do so, either xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-database-management[database management]
172+
or xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[alias management] privileges are required.
166173
The permission to create an alias can be granted like this:
167174

168175
[source, Cypher]
@@ -183,7 +190,7 @@ If a transaction modifies an alias (e.g. changing the database targeted on **DBM
183190
This prevents issues such as a transaction executing against multiple target databases for the same alias.
184191
====
185192

186-
== Change the encryption key
193+
=== Change the encryption key
187194

188195
If the encryption key in the keystore is changed, the encrypted credentials for existing remote database aliases will need to be updated as they will no longer be readable.
189196

@@ -193,6 +200,120 @@ If there is a failure when reading the keystore file, investigate the `debug.log
193200
In case it is not possible to connect to the remote alias after its creation, verify its settings by connecting to the remote database at https://browser.neo4j.io/ or at your local browser.
194201
====
195202

203+
[role=label--new-2025.10]
204+
[[setup-example-credential-forwarding]]
205+
== Setup example with OIDC credential forwarding
206+
207+
In order to use OIDC credential forwarding, both *DBMS A* and *DBMS B* need to support the same OIDC identity provider, see the xref:authentication-authorization/sso-integration.adoc[SSO integration] on how to enable OIDC.
208+
209+
In this example, _Alice_ is an administrator and _Carol_ is a user who needs access to a database managed by _Bob_:
210+
211+
In the example above, _Carol_ logs in to *DBMS A* through an OIDC compliant identity provider by offering a token from the provider.
212+
The token is used to set the username and determine the identity provider groups of the user.
213+
_Alice_ is the admin of *DBMS A* and has set up SSO for the identity provider and configured the mapping of the identity provider groups to the Neo4j roles, such that _Carol_ can use the remote database alias to connect to the remote database `Db1`.
214+
Additionally, _Bob_ needs to configure the *DBMS B* to support SSO with the same identity provider used by _Carol_ to log in to *DBMS A*. _Bob_ also needs to configure the mapping of the identity provider groups to the Neo4j roles such that the _Carol's_ identity provider groups gives the appropriate privileges to access `Db1` on the *DBMS B*.
215+
216+
217+
[CAUTION]
218+
====
219+
While it is permitted to use different OIDC configurations across distinct DBMS instances (e.g., local vs. target), users must be aware of the resulting privilege disparity.
220+
A user's effective permissions are not dictated by the identity provider groups alone, but by the mapping of those groups to the roles defined within each specific Neo4j DBMS, see xref:authentication-authorization/sso-integration.adoc#auth-sso-map-idp-roles[Map the identity provider groups to the Neo4j roles].
221+
Crucially, if the OIDC configuration settings differ between the local DBMS and the target DBMS, the user will have different effective privileges on those systems.
222+
This configuration independence can lead to privilege inconsistency (e.g., over-privileging or unexpected access denial).
223+
====
224+
225+
=== Configure a remote DBMS (_Bob_)
226+
227+
228+
In the suggested example, there are two administrators: _Alice_ and _Bob_.
229+
_Bob_ is the administrator responsible for the setup of the remote DBMS, which includes the following steps:
230+
231+
. Set up SSO and support for the identity provider.
232+
. Map the identity provider groups to the Neo4j roles. If you don’t want specific users to access `Db2`, here is where you set it.
233+
234+
Additionally, _Bob_ must do the required setup for the link:https://neo4j.com/docs/operations-manual/current/security/ssl-framework/[SSL framework] and check whether the database accepts a non-local connection if required.
235+
236+
[source, Example of additional configuration]
237+
----
238+
# accept non-local connections
239+
server.default_listen_address=0.0.0.0
240+
241+
# configure ssl for bolt
242+
dbms.ssl.policy.bolt.enabled=true
243+
dbms.ssl.policy.bolt.base_directory=certificates/bolt
244+
dbms.ssl.policy.bolt.private_key=private.key
245+
dbms.ssl.policy.bolt.public_certificate=public.crt
246+
dbms.ssl.policy.bolt.client_auth=NONE
247+
248+
# enforcing ssl connection
249+
server.bolt.tls_level=REQUIRED
250+
251+
# OIDC settings - these should be the same on both DBMSs
252+
dbms.security.oidc.<provider>.well_known_discovery_uri=http://example.com/.well-known/discovery
253+
<...>
254+
dbms.security.oidc.<provider>.claims.groups=groups
255+
dbms.security.oidc.<provider>.authorization.group_to_role_mapping= "engineers" = admin; \
256+
"collaborators" = reader
257+
----
258+
259+
=== Configure a DBMS with a remote database alias (_Alice_)
260+
261+
The steps _Alice_, need to take are:
262+
263+
. Set up SSO and support for the identity provider.
264+
. Map the identity provider groups to the Neo4j roles. This is where the permission to use the remote database alias is set.
265+
266+
[source, Example of additional configuration]
267+
----
268+
# OIDC settings - these should be the same on both DBMSs
269+
dbms.security.oidc.<provider>.well_known_discovery_uri=http://example.com/.well-known/discovery
270+
<...>
271+
dbms.security.oidc.<provider>.claims.groups=groups
272+
dbms.security.oidc.<provider>.authorization.group_to_role_mapping= "engineers" = admin; \
273+
"collaborators" = reader
274+
----
275+
=== Manage remote database aliases
276+
277+
You can use the xref:database-administration/aliases/manage-aliases-standard-databases.adoc[alias commands] to manage remote database aliases.
278+
In this case, it is strongly recommended to connect to a remote database alias with a secured connection.
279+
280+
Please note that only client-side SSL is supported.
281+
By default, remote aliases require a secured URI scheme such as `neo4j+s`.
282+
This can be disabled by setting the driver setting `ssl_enforced` to `false`.
283+
284+
For example, the following command can be used to create a remote database alias with OIDC credential forwarding:
285+
286+
[source, Cypher]
287+
----
288+
CREATE ALIAS `remote-neo4j` FOR DATABASE `neo4j` AT "neo4j+s://location:7687" OIDC CREDENTIAL FORWARDING
289+
----
290+
291+
In order to do so, either xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-database-management[database management]
292+
or xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[alias management] privileges are required.
293+
The permission to create an alias can be granted like this:
294+
295+
[source, Cypher]
296+
----
297+
GRANT CREATE ALIAS ON DBMS TO administrator
298+
----
299+
300+
Here is how to grant the xref:authentication-authorization/database-administration.adoc#access-control-database-administration-access[`ACCESS` privileges] to use the remote database alias:
301+
302+
[source, Cypher]
303+
----
304+
GRANT ACCESS ON DATABASE `remote-neo4j` TO admin
305+
----
306+
307+
In order for _Carol_ to get access to the remote database alias, she needs to be in an identity provider group that is mapped to a Neo4j role that is granted access to alias. In this example, if _Carol_ is in the identity provider group `engineers` which is mapped to the `admin` role, she will get the privileges of an `admin` and access to `remote-neo4j`.
308+
For details on how to map identity provider groups to Neo4j roles, see xref:authentication-authorization/sso-integration.adoc#auth-sso-map-idp-roles[Map the identity provider groups to the Neo4j roles].
309+
310+
[NOTE]
311+
====
312+
If a transaction modifies an alias (e.g. changing the database targeted on **DBMS B**), other transactions concurrently executing against that alias may be aborted and rolled back for safety.
313+
This prevents issues such as a transaction executing against multiple target databases for the same alias.
314+
====
315+
316+
196317
== Connect to remote database aliases
197318

198319
A user can connect to a remote database alias the same way they would do to a database.
@@ -208,7 +329,7 @@ USE `remote-neo4j` MATCH (n) RETURN *
208329

209330
* Connecting to a remote database alias as a home database.
210331
This needs to be set by Administrator A.
211-
See more about lxref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-user-management[User Management].
332+
See more about xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-user-management[User Management].
212333

213334
[source, Cypher]
214335
----
@@ -220,3 +341,15 @@ ALTER USER alice SET HOME DATABASE `remote-neo4j`
220341
Remote alias transactions will not be visible in `SHOW TRANSACTIONS` on **DBMS A**.
221342
However, they can be accessed and terminated on the remote database when connecting with the same user.
222343
====
344+
345+
[NOTE]
346+
====
347+
Action on the remote DBMS are all attributed to the user configured for the remote database alias.
348+
In the case of using `STORED NATIVE CREDENTIALS`, the same credentials are used to connect to the remote DBMS independent on which end-user made the query targeting the remote alias. This will result in the stored native user being logged in the audit trails on the remote DBMS for all queries using the remote database alias.
349+
When using `OIDC CREDENTIAL FORWARDING` the actual end-user's credentials and permissions will be used, this will result in per-user audit trails being logged on the remote DBMS.
350+
====
351+
352+
[NOTE]
353+
====
354+
When using a remote database alias with OIDC credential forwarding, the user needs to be logged in to the local DBMS with OIDC, otherwise there is no token to forward and the access to the remote database will be denied with `GQLSTATUS 42NFF`.
355+
====

0 commit comments

Comments
 (0)