Skip to content
Snippets Groups Projects
Commit 21b4bfed authored by Becker, Christoph's avatar Becker, Christoph
Browse files

Make mongodb auth mechanism configurable

parent 9fc78424
Branches
No related tags found
No related merge requests found
...@@ -63,8 +63,9 @@ func main() { ...@@ -63,8 +63,9 @@ func main() {
db, err := mongo.Connect( db, err := mongo.Connect(
context.Background(), context.Background(),
options.Client().ApplyURI(cfg.Mongo.Addr).SetAuth(options.Credential{ options.Client().ApplyURI(cfg.Mongo.Addr).SetAuth(options.Credential{
Username: cfg.Mongo.User, AuthMechanism: cfg.Mongo.AuthMechanism,
Password: cfg.Mongo.Pass, Username: cfg.Mongo.User,
Password: cfg.Mongo.Pass,
}), }),
) )
if err != nil { if err != nil {
......
...@@ -25,11 +25,12 @@ type httpConfig struct { ...@@ -25,11 +25,12 @@ type httpConfig struct {
} }
type mongoConfig struct { type mongoConfig struct {
Addr string `envconfig:"MONGO_ADDR" required:"true"` Addr string `envconfig:"MONGO_ADDR" required:"true"`
User string `envconfig:"MONGO_USER" required:"true"` User string `envconfig:"MONGO_USER" required:"true"`
Pass string `envconfig:"MONGO_PASS" required:"true"` Pass string `envconfig:"MONGO_PASS" required:"true"`
DB string `envconfig:"MONGO_DBNAME" default:"infohub"` DB string `envconfig:"MONGO_DBNAME" default:"infohub"`
Collection string `envconfig:"MONGO_COLLECTION" default:"exports"` Collection string `envconfig:"MONGO_COLLECTION" default:"exports"`
AuthMechanism string `envconfig:"MONGO_AUTH_MECHANISM" default:"SCRAM-SHA-1"`
} }
type credentialConfig struct { type credentialConfig struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment