CARVIEW |
Select Language
HTTP/2 200
date: Tue, 22 Jul 2025 08:33:57 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
x-repository-download: git clone https://github.com/neo4j/neo4j-javascript-driver.git
etag: W/"4dd7b00c3c3b4560943ecfe671b147f6"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=sCRiTlz29KEscexfRiXxTD%2BgpOoJ2LGcjeEDW%2B74FSYmzAoVbeH74MXEmmWuk7nigeS2Bhlr9Rs6o%2FyVbO1povMAVe%2BTV8%2B6RiCfi5VXJLCaYoog0QswqPqL8oUaI3ObTOHPpQtAl5c1Ue8DdH%2Fp6UJ3PBoGaHnCHxs%2FybIShhBrBa%2BDgYm7qqcjLIqayO5F7Fs0p7wTB%2Fk059HtE%2BhF%2FrJfoKvtjvqB8BHQT8JBHg37AMAHSt03xdrRG%2ByYbhjC0J4VwE%2FCMdqd6b568RHEFg%3D%3D--XEhEgrrl82ZWZCeb--Yjk6PKcIoDdmCyMbFZ2J6A%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1293574732.1753173236; Path=/; Domain=github.com; Expires=Wed, 22 Jul 2026 08:33:56 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Wed, 22 Jul 2026 08:33:56 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: C3BC:27D749:389C64:3F3D98:687F4CF4
Re-authentication (#1050) · neo4j/neo4j-javascript-driver@c4c0f9c · GitHub
⚠️ This API is released as preview.**
This changes introduce two ways of changing the connection credentials in a driver instance, each of them solving a different use case.
### Token Expiration / Change Credentials for the whole driver instance
This use case is related to the issue #993 in the repository. For solving this, the driver is now able to receive a `AuthTokenManager` in the driver creation. This interface enables the user code provide new auth tokens to the driver and be notified by token expiration failures.
For simplifying the usage, the driver also provides a default implementation of `AuthTokenManager` which can be created with `neo4j.temporalAuthDataManager` and receives a function for renewing the auth token as parameters.
Example:
```typescript
import neo4j, { AuthToken } from 'neo4j-driver'
/**
* Method called whenever the driver needs to refresh the token.
*
* The refresh will happen if the driver is notified by the server
* about a token expiration or if the `Date.now() > tokenData.expiry`
*
* Important, the driver will block all the connections creation until
* this function resolves the new auth token.
*/
async function fetchAuthTokenFromMyProvider () {
const bearer: string = await myProvider.getBearerToken()
const token: AuthToken = neo4j.auth.bearer(bearer)
const expiration: Date = myProvider.getExpiryDate()
return {
token,
// if expiration is not provided,
// the driver will only fetch a new token when a failure happens
expiration
}
}
const driver = neo4j.driver(
'neo4j://localhost:7687',
neo4j.expirationBasedAuthTokenManager({
getAuthData: fetchAuthTokenFromMyProvider
})
)
```
### User Switching
In this scenario, different credentials can be configured in a session providing a way for change the user context for the session. For using this feature, it needed to check if your server supports session auth by calling `driver.supportsSessionAuth()`.
Example:
```typescript
import neo4j from 'neo4j-driver'
const driver = neo4j.driver(
'neo4j://localhost:7687',
neo4j.auth.basic('neo4j', 'password')
)
const sessionWithUserB = driver.session({
database: 'neo4j',
auth: neo4j.auth.basic('userB', 'userBpassword')
})
try {
// run some queries as userB
const result = await sessionWithUserB.executeRead(tx => tx.run('RETURN 1'))
} finally {
// close the session as usual
await sessionWithUserB.close()
}
```
**⚠️ This API is released as preview.**Dismiss banner
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/bolt/bolt-protocol-v1.js
Copy file name to clipboard
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/connection-provider/connection-provider-direct.js
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/connection-provider/connection-provider-pooled.js
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit c4c0f9c
authored
Re-authentication (#1050)
**1 parent 93c0a16 commit c4c0f9cCopy full SHA for c4c0f9c
File tree
Expand file treeCollapse file tree
74 files changed
+5496
-490
lines changedFilter options
- packages
- bolt-connection
- src
- bolt
- connection-provider
- connection
- lang
- pool
- test
- connection-provider
- connection
- pool
- core
- src
- internal
- test
- neo4j-driver-deno/lib
- bolt-connection
- bolt
- connection-provider
- connection
- lang
- pool
- core
- internal
- neo4j-driver-lite
- src
- test/unit
- neo4j-driver
- src
- test
- internal
- types
- types
- testkit-backend
- deno
- src
- controller
- feature
- mock
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Expand file treeCollapse file tree
74 files changed
+5496
-490
lines changedpackages/bolt-connection/src/bolt/bolt-protocol-v1.js
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/bolt/bolt-protocol-v1.js+2Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
205 | 205 |
| |
206 | 206 |
| |
207 | 207 |
| |
| 208 | + | |
208 | 209 |
| |
209 | 210 |
| |
210 | 211 |
| |
| |||
233 | 234 |
| |
234 | 235 |
| |
235 | 236 |
| |
| 237 | + | |
236 | 238 |
| |
237 | 239 |
| |
238 | 240 |
| |
|
packages/bolt-connection/src/connection-provider/authentication-provider.js
Copy file name to clipboard+66Lines changed: 66 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + |
packages/bolt-connection/src/connection-provider/connection-provider-direct.js
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/connection-provider/connection-provider-direct.js+39-15Lines changed: 39 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
29 |
| - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
30 | 35 |
| |
31 | 36 |
| |
32 | 37 |
| |
33 | 38 |
| |
34 | 39 |
| |
35 |
| - | |
36 |
| - | |
| 40 | + | |
| 41 | + | |
37 | 42 |
| |
38 | 43 |
| |
39 | 44 |
| |
| |||
42 | 47 |
| |
43 | 48 |
| |
44 | 49 |
| |
45 |
| - | |
| 50 | + | |
46 | 51 |
| |
47 | 52 |
| |
48 |
| - | |
49 |
| - | |
| 53 | + | |
| 54 | + | |
50 | 55 |
| |
51 | 56 |
| |
52 |
| - | |
53 |
| - | |
54 |
| - | |
55 |
| - | |
56 |
| - | |
57 |
| - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
58 | 69 |
| |
59 | 70 |
| |
60 |
| - | |
| 71 | + | |
61 | 72 |
| |
62 | 73 |
| |
63 | 74 |
| |
64 |
| - | |
65 |
| - | |
| 75 | + | |
| 76 | + | |
66 | 77 |
| |
67 | 78 |
| |
68 | 79 |
| |
| |||
111 | 122 |
| |
112 | 123 |
| |
113 | 124 |
| |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
114 | 138 |
| |
115 | 139 |
| |
116 | 140 |
| |
|
packages/bolt-connection/src/connection-provider/connection-provider-pooled.js
Copy file name to clipboardExpand all lines: packages/bolt-connection/src/connection-provider/connection-provider-pooled.js+104-11Lines changed: 104 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
22 |
| - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
23 | 25 |
| |
24 | 26 |
| |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
25 | 34 |
| |
26 | 35 |
| |
27 |
| - | |
| 36 | + | |
28 | 37 |
| |
29 | 38 |
| |
30 | 39 |
| |
31 | 40 |
| |
32 | 41 |
| |
33 | 42 |
| |
34 | 43 |
| |
35 |
| - | |
36 |
| - | |
| 44 | + | |
| 45 | + | |
37 | 46 |
| |
38 | 47 |
| |
39 | 48 |
| |
| |||
44 | 53 |
| |
45 | 54 |
| |
46 | 55 |
| |
47 |
| - | |
| 56 | + | |
48 | 57 |
| |
49 | 58 |
| |
50 |
| - | |
| 59 | + | |
| 60 | + | |
51 | 61 |
| |
52 | 62 |
| |
53 | 63 |
| |
| |||
57 | 67 |
| |
58 | 68 |
| |
59 | 69 |
| |
| 70 | + | |
60 | 71 |
| |
61 | 72 |
| |
62 | 73 |
| |
| |||
69 | 80 |
| |
70 | 81 |
| |
71 | 82 |
| |
72 |
| - | |
| 83 | + | |
73 | 84 |
| |
74 | 85 |
| |
75 | 86 |
| |
76 | 87 |
| |
77 | 88 |
| |
78 |
| - | |
79 |
| - | |
| 89 | + | |
80 | 90 |
| |
81 | 91 |
| |
82 | 92 |
| |
| |||
86 | 96 |
| |
87 | 97 |
| |
88 | 98 |
| |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
89 | 119 |
| |
90 | 120 |
| |
91 | 121 |
| |
| |||
98 | 128 |
| |
99 | 129 |
| |
100 | 130 |
| |
101 |
| - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
102 | 136 |
| |
103 | 137 |
| |
104 | 138 |
| |
| |||
118 | 152 |
| |
119 | 153 |
| |
120 | 154 |
| |
121 |
| - | |
| 155 | + | |
122 | 156 |
| |
123 | 157 |
| |
124 | 158 |
| |
| |||
130 | 164 |
| |
131 | 165 |
| |
132 | 166 |
| |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
133 | 208 |
| |
134 | 209 |
| |
135 | 210 |
| |
| |||
146 | 221 |
| |
147 | 222 |
| |
148 | 223 |
| |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
149 | 242 |
|
You can’t perform that action at this time.
0 commit comments