From 763b6a0f63f3e18ff0ef423addf36035bb44cd00 Mon Sep 17 00:00:00 2001 From: Pasha Date: Thu, 28 Nov 2024 19:03:11 +0300 Subject: [PATCH] drop User Password Auth, only url and dbname --- mongo/config.go | 3 --- mongo/connection.go | 8 +------- mongo/mongo_test.go | 8 +------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/mongo/config.go b/mongo/config.go index 7861a88..bafa0cf 100644 --- a/mongo/config.go +++ b/mongo/config.go @@ -8,9 +8,6 @@ import ( type Configuration struct { URL string `env:"MONGO_URL,required"` - User string `env:"MONGO_USER,required"` - Password string `env:"MONGO_PASSWORD,required"` - Auth string `env:"MONGO_AUTH,required"` DatabaseName string `env:"MONGO_DB_NAME,required"` } diff --git a/mongo/connection.go b/mongo/connection.go index 3708a1d..2c7bbf4 100644 --- a/mongo/connection.go +++ b/mongo/connection.go @@ -40,13 +40,7 @@ func Connect(ctx context.Context, deps *ConnectDeps) (*mongo.Database, error) { } connectionOptions := options.Client(). - ApplyURI(deps.Configuration.URL). - SetAuth(options.Credential{ - AuthMechanism: "SCRAM-SHA-1", - AuthSource: deps.Configuration.Auth, - Username: deps.Configuration.User, - Password: deps.Configuration.Password, - }).SetMonitor(cmdMonitor) + ApplyURI(deps.Configuration.URL).SetMonitor(cmdMonitor) ticker := time.NewTicker(1 * time.Second) timeoutExceeded := time.After(deps.Timeout) diff --git a/mongo/mongo_test.go b/mongo/mongo_test.go index 4efb188..ebd1463 100644 --- a/mongo/mongo_test.go +++ b/mongo/mongo_test.go @@ -13,9 +13,6 @@ func TestConnectMongo(t *testing.T) { d, err := Connect(ctx, &ConnectDeps{ Configuration: &Configuration{ URL: "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0&readPreference=primary&ssl=false", - User: "test", - Password: "test", - Auth: "admin", DatabaseName: "test_replicaset", }, Timeout: 10 * time.Second, @@ -25,10 +22,7 @@ func TestConnectMongo(t *testing.T) { d2, err := Connect(ctx, &ConnectDeps{ Configuration: &Configuration{ - URL: "mongodb://localhost:27020/", - User: "test", - Password: "test", - Auth: "admin", + URL: "mongodb://test:test@localhost:27020/", DatabaseName: "test_default", }, Timeout: 10 * time.Second,