Details
-
Task
-
Resolution: Works as Designed
-
Critical - P2
-
None
-
None
-
None
-
None
Description
Iam able to connect mongo container versions 4.X and 5.X with the below code using amd64/mongo
auth := options.Credential{
|
AuthSource: admin,
|
Username: userName,
|
Password: pass,
|
}
|
opts := options.Client().ApplyURI(URI).SetAuth(auth).SetTLSConfig(&config)
|
client, err := mongo.Connect(ctx, opts)
|
But when i try to upgrade the container to version 6.0.2 from amd64/mongo
It fails with the below error
:Unable to connect to thecrdatabase :connection() error occurred during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed. |
I believe by default it tries to pick SCRAM-SHA-1
do I need to set a mongoDB server params in my mongo run script file like below ?
--authenticationMechanisms=SCRAM-SHA-1 |
All i'm trying to do is connect to db and change the admin and db password using below code , not sure even if this is depreciated now in the mongo version 6.0.2
res := struct{ Ok int }{} |
opts := options.RunCmd().SetReadPreference(readpref.Primary())
|
command := bson.D{{"updateUser", usrName}, {"pwd", pass}} |
err = client.Database(db).RunCommand(context.TODO(), command, opts).Decode(&res)
|
not sure where am I making mistake , the error message is not straight forward . Mongo doesn't give the actual error . Can anyone help me here ?