From 7aba10fa1adf11f2b7b57a479e1a41e3d0975473 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 9 Jun 2026 00:18:33 -0700 Subject: [PATCH] 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. --- weed/filer/mongodb/mongodb_store.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) }