Skip to content

Commit d70e5f4

Browse files
committed
Remove backwardsCompatibilityAuth code
1 parent bd0b52a commit d70e5f4

19 files changed

+246
-846
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default class DirectConnectionProvider extends PooledConnectionProvider {
4747
* See {@link ConnectionProvider} for more information about this method and
4848
* its arguments.
4949
*/
50-
async acquireConnection ({ accessMode, database, bookmarks, auth, allowStickyConnection, forceReAuth } = {}) {
50+
async acquireConnection ({ accessMode, database, bookmarks, auth, forceReAuth } = {}) {
5151
const databaseSpecificErrorHandler = ConnectionErrorHandler.create({
5252
errorCode: SERVICE_UNAVAILABLE,
5353
handleAuthorizationExpired: (error, address, conn) =>
@@ -57,15 +57,11 @@ export default class DirectConnectionProvider extends PooledConnectionProvider {
5757
const connection = await this._connectionPool.acquire({ auth, forceReAuth }, this._address)
5858

5959
if (auth) {
60-
const stickyConnection = await this._getStickyConnection({
60+
await this._verifyStickyConnection({
6161
auth,
6262
connection,
63-
address: this._address,
64-
allowStickyConnection
63+
address: this._address
6564
})
66-
if (stickyConnection) {
67-
return stickyConnection
68-
}
6965
return connection
7066
}
7167

@@ -132,9 +128,8 @@ export default class DirectConnectionProvider extends PooledConnectionProvider {
132128
)
133129
}
134130

135-
async verifyAuthentication ({ auth, allowStickyConnection }) {
131+
async verifyAuthentication ({ auth }) {
136132
return this._verifyAuthentication({
137-
allowStickyConnection,
138133
auth,
139134
getAddress: () => this._address
140135
})

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export default class PooledConnectionProvider extends ConnectionProvider {
164164
return serverInfo
165165
}
166166

167-
async _verifyAuthentication ({ getAddress, auth, allowStickyConnection }) {
167+
async _verifyAuthentication ({ getAddress, auth }) {
168168
const connectionsToRelease = []
169169
try {
170170
const address = await getAddress()
@@ -173,7 +173,7 @@ export default class PooledConnectionProvider extends ConnectionProvider {
173173

174174
const lastMessageIsNotLogin = !connection.protocol().isLastMessageLogon()
175175

176-
if (!connection.supportsReAuth && !allowStickyConnection) {
176+
if (!connection.supportsReAuth) {
177177
throw newError('Driver is connected to a database that does not support user switch.')
178178
}
179179
if (lastMessageIsNotLogin && connection.supportsReAuth) {
@@ -194,21 +194,14 @@ export default class PooledConnectionProvider extends ConnectionProvider {
194194
}
195195
}
196196

197-
async _getStickyConnection ({ auth, connection, address, allowStickyConnection }) {
197+
async _verifyStickyConnection ({ auth, connection, address }) {
198198
const connectionWithSameCredentials = object.equals(auth, connection.authToken)
199199
const shouldCreateStickyConnection = !connectionWithSameCredentials
200200
connection._sticky = connectionWithSameCredentials && !connection.supportsReAuth
201201

202-
if (allowStickyConnection !== true && (shouldCreateStickyConnection || connection._sticky)) {
202+
if (shouldCreateStickyConnection || connection._sticky) {
203203
await connection._release()
204204
throw newError('Driver is connected to a database that does not support user switch.')
205-
} else if (allowStickyConnection === true && shouldCreateStickyConnection) {
206-
await connection._release()
207-
connection = await this._connectionPool.acquire({ auth }, address, { requireNew: true })
208-
connection._sticky = true
209-
return connection
210-
} else if (connection._sticky) {
211-
return connection
212205
}
213206
}
214207

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

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
136136
* See {@link ConnectionProvider} for more information about this method and
137137
* its arguments.
138138
*/
139-
async acquireConnection ({ accessMode, database, bookmarks, impersonatedUser, onDatabaseNameResolved, auth, allowStickyConnection } = {}) {
139+
async acquireConnection ({ accessMode, database, bookmarks, impersonatedUser, onDatabaseNameResolved, auth } = {}) {
140140
let name
141141
let address
142142
const context = { database: database || DEFAULT_DB_NAME }
@@ -155,7 +155,6 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
155155
bookmarks,
156156
impersonatedUser,
157157
auth,
158-
allowStickyConnection,
159158
onDatabaseNameResolved: (databaseName) => {
160159
context.database = context.database || databaseName
161160
if (onDatabaseNameResolved) {
@@ -187,15 +186,11 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
187186
const connection = await this._connectionPool.acquire({ auth }, address)
188187

189188
if (auth) {
190-
const stickyConnection = await this._getStickyConnection({
189+
await this._verifyStickyConnection({
191190
auth,
192191
connection,
193-
address,
194-
allowStickyConnection
192+
address
195193
})
196-
if (stickyConnection) {
197-
return stickyConnection
198-
}
199194
return connection
200195
}
201196

@@ -275,9 +270,8 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
275270
})
276271
}
277272

278-
async verifyAuthentication ({ database, accessMode, auth, allowStickyConnection }) {
273+
async verifyAuthentication ({ database, accessMode, auth }) {
279274
return this._verifyAuthentication({
280-
allowStickyConnection,
281275
auth,
282276
getAddress: async () => {
283277
const context = { database: database || DEFAULT_DB_NAME }
@@ -286,7 +280,6 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
286280
accessMode,
287281
database: context.database,
288282
auth,
289-
allowStickyConnection,
290283
onDatabaseNameResolved: (databaseName) => {
291284
context.database = context.database || databaseName
292285
}
@@ -351,7 +344,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
351344
})
352345
}
353346

354-
_freshRoutingTable ({ accessMode, database, bookmarks, impersonatedUser, onDatabaseNameResolved, auth, allowStickyConnection } = {}) {
347+
_freshRoutingTable ({ accessMode, database, bookmarks, impersonatedUser, onDatabaseNameResolved, auth } = {}) {
355348
const currentRoutingTable = this._routingTableRegistry.get(
356349
database,
357350
() => new RoutingTable({ database })
@@ -363,10 +356,10 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
363356
this._log.info(
364357
`Routing table is stale for database: "${database}" and access mode: "${accessMode}": ${currentRoutingTable}`
365358
)
366-
return this._refreshRoutingTable(currentRoutingTable, bookmarks, impersonatedUser, onDatabaseNameResolved, auth, allowStickyConnection)
359+
return this._refreshRoutingTable(currentRoutingTable, bookmarks, impersonatedUser, onDatabaseNameResolved, auth)
367360
}
368361

369-
_refreshRoutingTable (currentRoutingTable, bookmarks, impersonatedUser, onDatabaseNameResolved, auth, allowStickyConnection) {
362+
_refreshRoutingTable (currentRoutingTable, bookmarks, impersonatedUser, onDatabaseNameResolved, auth) {
370363
const knownRouters = currentRoutingTable.routers
371364

372365
if (this._useSeedRouter) {
@@ -376,8 +369,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
376369
bookmarks,
377370
impersonatedUser,
378371
onDatabaseNameResolved,
379-
auth,
380-
allowStickyConnection
372+
auth
381373
)
382374
}
383375
return this._fetchRoutingTableFromKnownRoutersFallbackToSeedRouter(
@@ -386,8 +378,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
386378
bookmarks,
387379
impersonatedUser,
388380
onDatabaseNameResolved,
389-
auth,
390-
allowStickyConnection
381+
auth
391382
)
392383
}
393384

@@ -397,8 +388,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
397388
bookmarks,
398389
impersonatedUser,
399390
onDatabaseNameResolved,
400-
auth,
401-
allowStickyConnection
391+
auth
402392
) {
403393
// we start with seed router, no routers were probed before
404394
const seenRouters = []
@@ -408,8 +398,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
408398
currentRoutingTable,
409399
bookmarks,
410400
impersonatedUser,
411-
auth,
412-
allowStickyConnection
401+
auth
413402
)
414403

415404
if (newRoutingTable) {
@@ -421,8 +410,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
421410
currentRoutingTable,
422411
bookmarks,
423412
impersonatedUser,
424-
auth,
425-
allowStickyConnection
413+
auth
426414
)
427415
newRoutingTable = newRoutingTable2
428416
error = error2 || error
@@ -442,16 +430,14 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
442430
bookmarks,
443431
impersonatedUser,
444432
onDatabaseNameResolved,
445-
auth,
446-
allowStickyConnection
433+
auth
447434
) {
448435
let [newRoutingTable, error] = await this._fetchRoutingTableUsingKnownRouters(
449436
knownRouters,
450437
currentRoutingTable,
451438
bookmarks,
452439
impersonatedUser,
453-
auth,
454-
allowStickyConnection
440+
auth
455441
)
456442

457443
if (!newRoutingTable) {
@@ -462,8 +448,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
462448
currentRoutingTable,
463449
bookmarks,
464450
impersonatedUser,
465-
auth,
466-
allowStickyConnection
451+
auth
467452
)
468453
}
469454

@@ -480,16 +465,14 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
480465
currentRoutingTable,
481466
bookmarks,
482467
impersonatedUser,
483-
auth,
484-
allowStickyConnection
468+
auth
485469
) {
486470
const [newRoutingTable, error] = await this._fetchRoutingTable(
487471
knownRouters,
488472
currentRoutingTable,
489473
bookmarks,
490474
impersonatedUser,
491-
auth,
492-
allowStickyConnection
475+
auth
493476
)
494477

495478
if (newRoutingTable) {
@@ -515,8 +498,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
515498
routingTable,
516499
bookmarks,
517500
impersonatedUser,
518-
auth,
519-
allowStickyConnection
501+
auth
520502
) {
521503
const resolvedAddresses = await this._resolveSeedRouter(seedRouter)
522504

@@ -525,7 +507,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
525507
address => seenRouters.indexOf(address) < 0
526508
)
527509

528-
return await this._fetchRoutingTable(newAddresses, routingTable, bookmarks, impersonatedUser, auth, allowStickyConnection)
510+
return await this._fetchRoutingTable(newAddresses, routingTable, bookmarks, impersonatedUser, auth)
529511
}
530512

531513
async _resolveSeedRouter (seedRouter) {
@@ -537,7 +519,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
537519
return [].concat.apply([], dnsResolvedAddresses)
538520
}
539521

540-
async _fetchRoutingTable (routerAddresses, routingTable, bookmarks, impersonatedUser, auth, allowStickyConnection) {
522+
async _fetchRoutingTable (routerAddresses, routingTable, bookmarks, impersonatedUser, auth) {
541523
return routerAddresses.reduce(
542524
async (refreshedTablePromise, currentRouter, currentIndex) => {
543525
const [newRoutingTable] = await refreshedTablePromise
@@ -561,8 +543,7 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
561543
currentRouter,
562544
bookmarks,
563545
impersonatedUser,
564-
auth,
565-
allowStickyConnection
546+
auth
566547
)
567548
if (session) {
568549
try {
@@ -587,20 +568,16 @@ export default class RoutingConnectionProvider extends PooledConnectionProvider
587568
)
588569
}
589570

590-
async _createSessionForRediscovery (routerAddress, bookmarks, impersonatedUser, auth, allowStickyConnection) {
571+
async _createSessionForRediscovery (routerAddress, bookmarks, impersonatedUser, auth) {
591572
try {
592-
let connection = await this._connectionPool.acquire({ auth }, routerAddress)
573+
const connection = await this._connectionPool.acquire({ auth }, routerAddress)
593574

594575
if (auth) {
595-
const stickyConnection = await this._getStickyConnection({
576+
await this._verifyStickyConnection({
596577
auth,
597578
connection,
598-
address: routerAddress,
599-
allowStickyConnection
579+
address: routerAddress
600580
})
601-
if (stickyConnection) {
602-
connection = stickyConnection
603-
}
604581
}
605582

606583
const databaseSpecificErrorHandler = ConnectionErrorHandler.create({

0 commit comments

Comments
 (0)