mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-06-13 23:36:45 +03:00
fix(mongodb): merge URI auth fields with username/password override (#9889)
* fix(mongodb): merge URI auth fields with username/password override SetAuth replaced the whole Credential parsed from the URI, dropping AuthSource and AuthMechanism. Start from the URI-parsed Auth and only override the username and password so credentials scoped to a specific auth database keep working. * fix(mongodb): set PasswordSet for explicit credentials Required by GSSAPI auth when a password is supplied; ignored for other mechanisms.
This commit is contained in:
@@ -74,10 +74,15 @@ func (store *MongodbStore) connection(uri string, poolSize uint64, ssl bool, ssl
|
||||
}
|
||||
|
||||
if username != "" && password != "" {
|
||||
creds := options.Credential{
|
||||
Username: username,
|
||||
Password: password,
|
||||
// Keep auth fields parsed from the URI (AuthSource, AuthMechanism, ...)
|
||||
// and only override the credentials.
|
||||
creds := options.Credential{}
|
||||
if opts.Auth != nil {
|
||||
creds = *opts.Auth
|
||||
}
|
||||
creds.Username = username
|
||||
creds.Password = password
|
||||
creds.PasswordSet = true
|
||||
opts.SetAuth(creds)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user