Skip to content

Commit 88db1a2

Browse files
committed
Ensure speculative auth uses the credentials auth source. (#781)
JAVA-4290
1 parent 926bd7f commit 88db1a2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

driver-core/src/main/com/mongodb/internal/connection/ScramShaAuthenticator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public BsonDocument createSpeculativeAuthenticateCommand(final InternalConnectio
9999
try {
100100
speculativeSaslClient = createSaslClient(connection.getDescription().getServerAddress());
101101
BsonDocument startDocument = createSaslStartCommandDocument(speculativeSaslClient.evaluateChallenge(new byte[0]))
102-
.append("db", new BsonString("admin"));
102+
.append("db", new BsonString(getMongoCredential().getSource()));
103103
appendSaslStartOptions(startDocument);
104104
return startDocument;
105105
} catch (Exception e) {

driver-core/src/test/unit/com/mongodb/internal/connection/InternalStreamConnectionInitializerSpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
540540
"mechanism: '${mechanism}', db: \"\$external\" } }" :
541541
'speculativeAuthenticate: { saslStart: 1, ' +
542542
"mechanism: '${mechanism}', payload: BinData(0, '${encode64(firstClientChallenge)}'), " +
543-
'db: "admin", options: { skipEmptyExchange: true } } }')
543+
'db: "database", options: { skipEmptyExchange: true } } }')
544544

545545
BsonDocument.parse(isMaster)
546546
}

driver-core/src/test/unit/com/mongodb/internal/connection/ScramShaAuthenticatorSpecification.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class ScramShaAuthenticatorSpecification extends Specification {
7878
def firstClientChallenge = 'n,,n=user,r=fyko+d2lbbFgONRv9qkxdawL'
7979
def expectedSpeculativeAuthenticateCommand = BsonDocument.parse('{ saslStart: 1, mechanism: "SCRAM-SHA-1", '
8080
+ "payload: BinData(0, '${encode64(firstClientChallenge)}'), "
81-
+ 'db: "admin", options: { skipEmptyExchange: true }}')
81+
+ 'db: "database", options: { skipEmptyExchange: true }}')
8282
def serverResponse = 'r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096'
8383
def speculativeAuthenticateResponse =
8484
BsonDocument.parse("{ conversationId: 1, payload: BinData(0, '${encode64(serverResponse)}'), done: false }")
@@ -132,7 +132,7 @@ class ScramShaAuthenticatorSpecification extends Specification {
132132
def firstClientChallenge = 'n,,n=user,r=rOprNGfwEbeRWgbNEkqO'
133133
def expectedSpeculativeAuthenticateCommand = BsonDocument.parse('{ saslStart: 1, mechanism: "SCRAM-SHA-256", '
134134
+ "payload: BinData(0, '${encode64(firstClientChallenge)}'), "
135-
+ 'db: "admin", options: { skipEmptyExchange: true }}')
135+
+ 'db: "database", options: { skipEmptyExchange: true }}')
136136
def serverResponse = 'r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,s=W22ZaJ0SNY7soEsUEjb6gQ==,i=4096'
137137
def speculativeAuthenticateResponse =
138138
BsonDocument.parse("{ conversationId: 1, payload: BinData(0, '${encode64(serverResponse)}'), done: false }")

0 commit comments

Comments
 (0)