Skip to content

Commit 4869203

Browse files
committed
Session config
1 parent d349b89 commit 4869203

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

packages/bolt-connection/src/connection-provider/connection-provider-direct.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,34 @@ export default class DirectConnectionProvider extends PooledConnectionProvider {
4242
* See {@link ConnectionProvider} for more information about this method and
4343
* its arguments.
4444
*/
45-
acquireConnection ({ accessMode, database, bookmarks } = {}) {
45+
async acquireConnection ({ accessMode, database, bookmarks, auth } = {}) {
4646
const databaseSpecificErrorHandler = ConnectionErrorHandler.create({
4747
errorCode: SERVICE_UNAVAILABLE,
4848
handleAuthorizationExpired: (error, address, conn) =>
4949
this._handleAuthorizationExpired(error, address, conn, database)
5050
})
5151

52-
return this._connectionPool
53-
.acquire(this._address)
54-
.then(
55-
connection =>
56-
new DelegateConnection(connection, databaseSpecificErrorHandler)
57-
)
52+
const connection = await this._connectionPool.acquire(this._address)
53+
54+
if (auth && auth !== connection.authToken) {
55+
if (connection.supportsReAuth) {
56+
await connection.connect(this._userAgent, auth)
57+
} else {
58+
await connection._release()
59+
return await this._createStickyConnection({ address: this._address, auth })
60+
}
61+
}
62+
63+
return new DelegateConnection(connection, databaseSpecificErrorHandler)
5864
}
5965

6066
_handleAuthorizationExpired (error, address, connection, database) {
6167
this._log.warn(
6268
`Direct driver ${this._id} will close connection to ${address} for database '${database}' because of an error ${error.code} '${error.message}'`
6369
)
64-
70+
6571
this._authenticationProvider.handleError({ connection, code: error.code })
66-
72+
6773
if (error.code === 'Neo.ClientError.Security.AuthorizationExpired') {
6874
this._connectionPool.apply(address, (conn) => conn.authToken === null)
6975
}

packages/testkit-backend/src/feature/common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const features = [
44
'Feature:Auth:Kerberos',
55
'Feature:Auth:Bearer',
66
'Feature:API:BookmarkManager',
7+
'Feature:API:Session:AuthConfig',
78
'Feature:API:SSLConfig',
89
'Feature:API:SSLSchemes',
910
'Feature:API:Type.Temporal',

packages/testkit-backend/src/request-handlers.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,19 @@ export function NewSession (neo4j, context, data, wire) {
116116
return
117117
}
118118
}
119+
const auth = data.authorizationToken != null
120+
? context.binder.parseAuthToken(data.authorizationToken.data)
121+
: undefined
122+
119123
const driver = context.getDriver(driverId)
120124
const session = driver.session({
121125
defaultAccessMode: accessMode,
122126
bookmarks,
123127
database,
124128
fetchSize,
125129
impersonatedUser,
126-
bookmarkManager
130+
bookmarkManager,
131+
auth
127132
})
128133
const id = context.addSession(session)
129134
wire.writeResponse(responses.Session({ id }))

0 commit comments

Comments
 (0)