@@ -188,6 +188,7 @@ func NewAuthenticatorConfig(authenticator driver.Authenticator, clientOpts ...Au
188188
189189 opts := settings .opts
190190 clock := settings .clock
191+ driverInfo := settings .driverInfo
191192
192193 var serverAPI * driver.ServerAPIOptions
193194
@@ -242,8 +243,8 @@ func NewAuthenticatorConfig(authenticator driver.Authenticator, clientOpts ...Au
242243 }))
243244 }
244245
245- if settings . driverInfo != nil {
246- serverOpts = append (serverOpts , WithDriverInfo (settings . driverInfo ))
246+ if driverInfo != nil {
247+ serverOpts = append (serverOpts , WithDriverInfo (driverInfo ))
247248 }
248249
249250 // Compressors & ZlibLevel
@@ -283,37 +284,38 @@ func NewAuthenticatorConfig(authenticator driver.Authenticator, clientOpts ...Au
283284 // Handshaker
284285 var handshaker func (driver.Handshaker ) driver.Handshaker
285286 if authenticator != nil {
286- handshakeOpts := & auth.HandshakeOptions {
287- AppName : appName ,
288- Authenticator : authenticator ,
289- Compressors : comps ,
290- ServerAPI : serverAPI ,
291- LoadBalanced : loadBalanced ,
292- ClusterClock : clock ,
293- }
287+ handshaker = func (driver.Handshaker ) driver.Handshaker {
288+ handshakeOpts := & auth.HandshakeOptions {
289+ AppName : appName ,
290+ Authenticator : authenticator ,
291+ Compressors : comps ,
292+ ServerAPI : serverAPI ,
293+ LoadBalanced : loadBalanced ,
294+ ClusterClock : clock ,
295+ }
294296
295- if settings .driverInfo != nil {
296- if di := settings .driverInfo .Load (); di != nil {
297- handshakeOpts .OuterLibraryName = di .Name
298- handshakeOpts .OuterLibraryVersion = di .Version
299- handshakeOpts .OuterLibraryPlatform = di .Platform
297+ if opts .Auth .AuthMechanism == "" {
298+ // Required for SASL mechanism negotiation during handshake
299+ handshakeOpts .DBUser = opts .Auth .AuthSource + "." + opts .Auth .Username
300300 }
301- }
302301
303- if opts .Auth .AuthMechanism == "" {
304- // Required for SASL mechanism negotiation during handshake
305- handshakeOpts .DBUser = opts .Auth .AuthSource + "." + opts .Auth .Username
306- }
307- if a := optionsutil .Value (opts .Custom , "authenticateToAnything" ); a != nil {
308- if v , ok := a .(bool ); ok && v {
309- // Authenticate arbiters
310- handshakeOpts .PerformAuthentication = func (_ description.Server ) bool {
311- return true
302+ if a := optionsutil .Value (opts .Custom , "authenticateToAnything" ); a != nil {
303+ if v , ok := a .(bool ); ok && v {
304+ // Authenticate arbiters
305+ handshakeOpts .PerformAuthentication = func (_ description.Server ) bool {
306+ return true
307+ }
308+ }
309+ }
310+
311+ if driverInfo != nil {
312+ if di := driverInfo .Load (); di != nil {
313+ handshakeOpts .OuterLibraryName = di .Name
314+ handshakeOpts .OuterLibraryVersion = di .Version
315+ handshakeOpts .OuterLibraryPlatform = di .Platform
312316 }
313317 }
314- }
315318
316- handshaker = func (driver.Handshaker ) driver.Handshaker {
317319 return auth .Handshaker (nil , handshakeOpts )
318320 }
319321
@@ -326,8 +328,8 @@ func NewAuthenticatorConfig(authenticator driver.Authenticator, clientOpts ...Au
326328 ServerAPI (serverAPI ).
327329 LoadBalanced (loadBalanced )
328330
329- if settings . driverInfo != nil {
330- if di := settings . driverInfo .Load (); di != nil {
331+ if driverInfo != nil {
332+ if di := driverInfo .Load (); di != nil {
331333 op = op .OuterLibraryName (di .Name ).
332334 OuterLibraryVersion (di .Version ).
333335 OuterLibraryPlatform (di .Platform )
0 commit comments