Skip to content

Commit

Permalink
Ensure speculative auth uses the credentials auth source. (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
rozza committed Sep 7, 2021
1 parent 926bd7f commit 88db1a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public BsonDocument createSpeculativeAuthenticateCommand(final InternalConnectio
try {
speculativeSaslClient = createSaslClient(connection.getDescription().getServerAddress());
BsonDocument startDocument = createSaslStartCommandDocument(speculativeSaslClient.evaluateChallenge(new byte[0]))
.append("db", new BsonString("admin"));
.append("db", new BsonString(getMongoCredential().getSource()));
appendSaslStartOptions(startDocument);
return startDocument;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
"mechanism: '${mechanism}', db: \"\$external\" } }" :
'speculativeAuthenticate: { saslStart: 1, ' +
"mechanism: '${mechanism}', payload: BinData(0, '${encode64(firstClientChallenge)}'), " +
'db: "admin", options: { skipEmptyExchange: true } } }')
'db: "database", options: { skipEmptyExchange: true } } }')

BsonDocument.parse(isMaster)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ScramShaAuthenticatorSpecification extends Specification {
def firstClientChallenge = 'n,,n=user,r=fyko+d2lbbFgONRv9qkxdawL'
def expectedSpeculativeAuthenticateCommand = BsonDocument.parse('{ saslStart: 1, mechanism: "SCRAM-SHA-1", '
+ "payload: BinData(0, '${encode64(firstClientChallenge)}'), "
+ 'db: "admin", options: { skipEmptyExchange: true }}')
+ 'db: "database", options: { skipEmptyExchange: true }}')
def serverResponse = 'r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096'
def speculativeAuthenticateResponse =
BsonDocument.parse("{ conversationId: 1, payload: BinData(0, '${encode64(serverResponse)}'), done: false }")
Expand Down Expand Up @@ -132,7 +132,7 @@ class ScramShaAuthenticatorSpecification extends Specification {
def firstClientChallenge = 'n,,n=user,r=rOprNGfwEbeRWgbNEkqO'
def expectedSpeculativeAuthenticateCommand = BsonDocument.parse('{ saslStart: 1, mechanism: "SCRAM-SHA-256", '
+ "payload: BinData(0, '${encode64(firstClientChallenge)}'), "
+ 'db: "admin", options: { skipEmptyExchange: true }}')
+ 'db: "database", options: { skipEmptyExchange: true }}')
def serverResponse = 'r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,s=W22ZaJ0SNY7soEsUEjb6gQ==,i=4096'
def speculativeAuthenticateResponse =
BsonDocument.parse("{ conversationId: 1, payload: BinData(0, '${encode64(serverResponse)}'), done: false }")
Expand Down

0 comments on commit 88db1a2

Please sign in to comment.