You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: go-manual/modules/ROOT/pages/query-simple.adoc
+19-6
Original file line number
Diff line number
Diff line change
@@ -227,24 +227,37 @@ In other words, there is no guarantee that a write query submitted in read mode
227
227
228
228
229
229
[#impersonation]
230
+
[role=label--new-5.14]
230
231
=== Run queries as a different user
231
232
232
-
You can execute a query under the security context of a different user with the callback `neo4j.ExecuteQueryWithImpersonatedUser("<somebodyElse>")`, specifying the name of the user to impersonate.
233
-
For this to work, the user under which the `DriverWithContext` object
234
-
was created needs to have the link:{neo4j-docs-base-uri}/cypher-manual/current/administration/access-control/dbms-administration#access-control-dbms-administration-impersonation[appropriate permissions].
235
-
Impersonating a user is cheaper than creating a new `DriverWithContext` object.
233
+
You can execute a query through a different user with the configuration callback `neo4j.ExecuteQueryWithAuthToken()`.
234
+
Switching user at the query level is cheaper than creating a new `DriverWithContext` object.
235
+
The query is then run within the security context of the given user (i.e., home database, permissions, etc.). +
236
+
Query-scoped authentication a server version >= 5.8.
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
249
+
The callback `neo4j.ExecuteQueryWithImpersonatedUser()` provides a similar functionality, and is available in driver/server versions >= 4.4.
250
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
Copy file name to clipboardExpand all lines: go-manual/modules/ROOT/pages/transactions.adoc
+18-6
Original file line number
Diff line number
Diff line change
@@ -494,21 +494,33 @@ Similar remarks hold for the `.ExecuteRead()` and `.ExecuteWrite()` methods.
494
494
495
495
496
496
[#impersonation]
497
-
=== Run queries as a different user (impersonation)
497
+
[role=label--new-5.14]
498
+
=== Run queries as a different user
498
499
499
-
You can execute a query under the security context of a different user with the configuration parameter `ImpersonatedUser`, specifying the name of the user to impersonate.
500
-
For this to work, the user under which the `DriverWithContext` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
501
-
Impersonating a user is cheaper than creating a new `DriverWithContext` object.
500
+
You can execute a query through a different user with the configuration option `Auth`.
501
+
Switching user at the session level is cheaper than creating a new `DriverWithContext` object.
502
+
Queries are then run within the security context of the given user (i.e., home database, permissions, etc.). +
503
+
Session-scoped authentication requires a server version >= 5.8.
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
514
+
The option `ImpersonatedUser` provides a similar functionality, and is available in driver/server versions >= 4.4.
515
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
Copy file name to clipboardExpand all lines: java-manual/modules/ROOT/pages/query-simple.adoc
+22-5
Original file line number
Diff line number
Diff line change
@@ -234,25 +234,42 @@ In other words, there is no guarantee that a write query submitted in read mode
234
234
235
235
236
236
[#impersonation]
237
+
[role=label--new-5.18]
237
238
=== Run queries as a different user
238
239
239
-
You can execute a query under the security context of a different user with the method `.withImpersonatedUser("<username>")`, specifying the name of the user to impersonate.
240
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/cypher-manual/current/administration/access-control/dbms-administration#access-control-dbms-administration-impersonation[appropriate permissions].
241
-
Impersonating a user is cheaper than creating a new `Driver` object.
240
+
You can execute a query through a different user with the method `.withAuthToken()`.
241
+
Switching user at the query level is cheaper than creating a new `Driver` object.
242
+
The query is then run within the security context of the given user (i.e., home database, permissions, etc.). +
243
+
Query-scoped authentication a server version >= 5.8.
242
244
243
245
[source, java, test-skip]
244
246
----
247
+
// import org.neo4j.driver.AuthTokens;
245
248
// import org.neo4j.driver.QueryConfig;
246
249
250
+
var authToken = AuthTokens.basic("somebodyElse", "theirPassword");
247
251
var result = driver.executableQuery("MATCH (p:Person) RETURN p.name")
248
252
.withConfig(QueryConfig.builder()
249
253
.withDatabase("neo4j")
250
-
.withImpersonatedUser("somebodyElse")
254
+
.withAuthToken(authToken)
251
255
.build())
252
256
.execute();
253
257
----
254
258
255
-
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
259
+
The method `.withImpersonatedUser()` provides a similar functionality, and is available in driver/server versions >= 4.4.
260
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
261
+
262
+
[source, java, test-skip]
263
+
----
264
+
// import org.neo4j.driver.QueryConfig;
265
+
266
+
var result = driver.executableQuery("MATCH (p:Person) RETURN p.name")
Copy file name to clipboardExpand all lines: java-manual/modules/ROOT/pages/transactions.adoc
+25-7
Original file line number
Diff line number
Diff line change
@@ -447,25 +447,43 @@ Similar remarks hold for the `.executeRead()` and `.executeWrite()` methods.
447
447
448
448
449
449
[#impersonation]
450
-
=== Run queries as a different user (impersonation)
450
+
[role=label--new-5.18]
451
+
=== Run queries as a different user
451
452
452
-
You can execute a query under the security context of a different user with the method `.withImpersonatedUser("<username>")`, specifying the name of the user to impersonate.
453
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
454
-
Impersonating a user is cheaper than creating a new `Driver` object.
453
+
You can execute a query through a different user by providing an link:https://neo4j.com/docs/api/java-driver/current/org.neo4j.driver/org/neo4j/driver/AuthTokens.html[AuthToken] as third parameter upon session creation.
454
+
Switching user at the session level is cheaper than creating a new `Driver` object.
455
+
Queries are then run within the security context of the given user (i.e., home database, permissions, etc.). +
456
+
Session-scoped authentication requires a server version >= 5.8.
457
+
458
+
[source, java]
459
+
----
460
+
// import org.neo4j.driver.AuthTokens;
461
+
// import org.neo4j.driver.Session;
462
+
// import org.neo4j.driver.SessionConfig;
463
+
464
+
var authToken = AuthTokens.basic("somebodyElse", "theirPassword");
465
+
var session = driver.session(
466
+
Session.class,
467
+
SessionConfig.builder()
468
+
.withDatabase("neo4j")
469
+
.build(),
470
+
authToken
471
+
);
472
+
----
473
+
474
+
The method `.withImpersonatedUser()` provides a similar functionality, and is available in driver/server versions >= 4.4.
475
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
455
476
456
477
[source, java]
457
478
----
458
479
// import org.neo4j.driver.SessionConfig;
459
-
// import org.neo4j.driver.RoutingControl;
460
480
461
481
var session = driver.session(SessionConfig.builder()
462
482
.withDatabase("neo4j")
463
483
.withImpersonatedUser("somebodyElse")
464
484
.build());
465
485
----
466
486
467
-
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
Copy file name to clipboardExpand all lines: javascript-manual/modules/ROOT/pages/query-simple.adoc
+20-5
Original file line number
Diff line number
Diff line change
@@ -210,25 +210,40 @@ In other words, there is no guarantee that a write query submitted in read mode
210
210
211
211
212
212
[#impersonation]
213
+
[role=label--new-5.14]
213
214
=== Run queries as a different user
214
215
215
-
You can execute a query under the security context of a different user with the parameter `impersonatedUser`, specifying the name of the user to impersonate.
216
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/cypher-manual/current/administration/access-control/dbms-administration#access-control-dbms-administration-impersonation[appropriate permissions].
217
-
Impersonating a user is cheaper than creating a new `Driver` object.
216
+
You can execute a query through a different user with the configuration parameter `auth`.
217
+
Switching user at the query level is cheaper than creating a new `Driver` object.
218
+
The query is then run within the security context of the given user (i.e., home database, permissions, etc.). +
219
+
Query-scoped authentication a server version >= 5.8.
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
233
+
The parameter `impersonatedUser` provides a similar functionality, and is available in driver/server versions >= 4.4.
234
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
Copy file name to clipboardExpand all lines: javascript-manual/modules/ROOT/pages/transactions.adoc
+17-6
Original file line number
Diff line number
Diff line change
@@ -330,21 +330,32 @@ Similar remarks hold for the `.executeRead()` and `.executeWrite()` methods.
330
330
331
331
332
332
[#impersonation]
333
-
=== Run queries as a different user (impersonation)
333
+
[role=label--new-5.14]
334
+
=== Run queries as a different user
334
335
335
-
You can execute a query under the security context of a different user with the parameter `impersonatedUser`, specifying the name of the user to impersonate.
336
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
337
-
Impersonating a user is cheaper than creating a new `Driver` object.
336
+
You can execute a query through a different user with the configuration parameter `auth`.
337
+
Switching user at the session level is cheaper than creating a new `Driver` object.
338
+
Queries are then run within the security context of the given user (i.e., home database, permissions, etc.). +
339
+
Session-scoped authentication requires a server version >= 5.8.
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e., home database, permissions, etc.).
349
+
The parameter `impersonatedUser` provides a similar functionality, and is available in driver/server versions >= 4.4.
350
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
Copy file name to clipboardExpand all lines: python-manual/modules/ROOT/pages/query-simple.adoc
+17-5
Original file line number
Diff line number
Diff line change
@@ -216,22 +216,34 @@ In other words, there is no guarantee that a write query submitted in read mode
216
216
217
217
218
218
[#impersonation]
219
+
[role=label--new-5.14]
219
220
=== Run queries as a different user
220
221
221
-
You can execute a query under the security context of a different user with the parameter `impersonated_user_`, specifying the name of the user to impersonate.
222
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/cypher-manual/current/administration/access-control/dbms-administration#access-control-dbms-administration-impersonation[appropriate permissions].
223
-
Impersonating a user is cheaper than creating a new `Driver` object.
222
+
You can execute a query through a different user with the parameter `auth_`.
223
+
Switching user at the query level is cheaper than creating a new `Driver` object.
224
+
The query is then run within the security context of the given user (i.e., home database, permissions, etc.). +
225
+
Query-scoped authentication a server version >= 5.8.
224
226
225
227
[source, python, test-skip]
226
228
----
227
229
driver.execute_query(
228
230
"MATCH (p:Person) RETURN p.name",
229
-
impersonated_user_="somebody_else",
231
+
auth_=("somebody_else", "their_password"),
230
232
database_="neo4j",
231
233
)
232
234
----
233
235
234
-
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e. home database, permissions, etc.).
236
+
The parameter `impersonated_user_` provides a similar functionality, and is available in driver/server versions >= 4.4.
237
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
Copy file name to clipboardExpand all lines: python-manual/modules/ROOT/pages/transactions.adoc
+17-6
Original file line number
Diff line number
Diff line change
@@ -410,23 +410,34 @@ Similar remarks hold for the `.executeRead()` and `.executeWrite()` methods.
410
410
411
411
412
412
[#impersonation]
413
-
=== Run queries as a different user (impersonation)
413
+
[role=label--new-5.14]
414
+
=== Run queries as a different user
414
415
415
-
You can execute a query under the security context of a different user with the parameter `impersonated_user`, specifying the name of the user to impersonate.
416
-
For this to work, the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
417
-
Impersonating a user is cheaper than creating a new `Driver` object.
416
+
You can execute a query through a different user with the parameter `auth`.
417
+
Switching user at the session level is cheaper than creating a new `Driver` object.
418
+
Queries are then run within the security context of the given user (i.e., home database, permissions, etc.). +
419
+
Session-scoped authentication requires a server version >= 5.8.
418
420
419
421
[source, python]
420
422
----
421
423
with driver.session(
422
424
database="neo4j",
423
-
impersonated_user="somebody_else"
425
+
auth=("somebody_else", "their_password")
424
426
) as session:
425
427
...
426
428
----
427
429
428
-
When impersonating a user, the query is run within the complete security context of the impersonated user and not the authenticated user (i.e., home database, permissions, etc.).
430
+
The parameter `impersonated_user` provides a similar functionality, and is available in driver/server versions >= 4.4.
431
+
The difference is that you don't need to know a user's password to impersonate them, but the user under which the `Driver` was created needs to have the link:{neo4j-docs-base-uri}/operations-manual/current/authentication-authorization/dbms-administration/#access-control-dbms-administration-impersonation[appropriate permissions].
0 commit comments