diff --git a/weed/filer/mongodb/mongodb_store.go b/weed/filer/mongodb/mongodb_store.go index f87878f08..cbdfe7f54 100644 --- a/weed/filer/mongodb/mongodb_store.go +++ b/weed/filer/mongodb/mongodb_store.go @@ -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) }