Skip to content

Commit 07cde68

Browse files
jedyang01471076
andauthored
mongo use auth-source (#1635)
Co-authored-by: 01471076 <[email protected]>
1 parent 26606f1 commit 07cde68

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

server/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mongo:
3030
database: ''
3131
username: ''
3232
password: ''
33+
auth-source: ''
3334
min-pool-size: 0
3435
max-pool-size: 100
3536
socket-timeout-ms: 0

server/config/mongo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Mongo struct {
1111
Database string `json:"database" yaml:"database" mapstructure:"database"` // database name
1212
Username string `json:"username" yaml:"username" mapstructure:"username"` // 用户名
1313
Password string `json:"password" yaml:"password" mapstructure:"password"` // 密码
14+
AuthSource string `json:"auth-source" yaml:"auth-source" mapstructure:"auth-source"` // 验证数据库
1415
MinPoolSize uint64 `json:"min-pool-size" yaml:"min-pool-size" mapstructure:"min-pool-size"` // 最小连接池
1516
MaxPoolSize uint64 `json:"max-pool-size" yaml:"max-pool-size" mapstructure:"max-pool-size"` // 最大连接池
1617
SocketTimeoutMs int64 `json:"socket-timeout-ms" yaml:"socket-timeout-ms" mapstructure:"socket-timeout-ms"` // socket超时时间

server/initialize/mongo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ func (m *mongo) Initialization() error {
5454
SocketTimeoutMS: &global.GVA_CONFIG.Mongo.SocketTimeoutMs,
5555
ConnectTimeoutMS: &global.GVA_CONFIG.Mongo.ConnectTimeoutMs,
5656
Auth: &qmgo.Credential{
57-
Username: global.GVA_CONFIG.Mongo.Username,
58-
Password: global.GVA_CONFIG.Mongo.Password,
57+
Username: global.GVA_CONFIG.Mongo.Username,
58+
Password: global.GVA_CONFIG.Mongo.Password,
59+
AuthSource: global.GVA_CONFIG.Mongo.AuthSource,
5960
},
6061
}, opts...)
6162
if err != nil {

0 commit comments

Comments
 (0)