mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-24 11:09:12 +08:00
Feat: support username/password authentication for etcd filer store s… (#4477)
Feat: support username/password authentication for etcd filer store seaweedfs/seaweedfs#4262 Co-authored-by: Mesar Hameed <mesar.hameed@gmail.com>
This commit is contained in:
parent
64b2fbe0f1
commit
65484e80ef
@ -262,6 +262,8 @@ routeByLatency = false
|
|||||||
[etcd]
|
[etcd]
|
||||||
enabled = false
|
enabled = false
|
||||||
servers = "localhost:2379"
|
servers = "localhost:2379"
|
||||||
|
username = ""
|
||||||
|
password = ""
|
||||||
timeout = "3s"
|
timeout = "3s"
|
||||||
|
|
||||||
[mongodb]
|
[mongodb]
|
||||||
|
@ -37,15 +37,18 @@ func (store *EtcdStore) Initialize(configuration weed_util.Configuration, prefix
|
|||||||
servers = "localhost:2379"
|
servers = "localhost:2379"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
username := configuration.GetString(prefix + "username")
|
||||||
|
password := configuration.GetString(prefix + "password")
|
||||||
|
|
||||||
timeout := configuration.GetString(prefix + "timeout")
|
timeout := configuration.GetString(prefix + "timeout")
|
||||||
if timeout == "" {
|
if timeout == "" {
|
||||||
timeout = "3s"
|
timeout = "3s"
|
||||||
}
|
}
|
||||||
|
|
||||||
return store.initialize(servers, timeout)
|
return store.initialize(servers, username, password, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *EtcdStore) initialize(servers string, timeout string) (err error) {
|
func (store *EtcdStore) initialize(servers string, username string, password string, timeout string) (err error) {
|
||||||
glog.Infof("filer store etcd: %s", servers)
|
glog.Infof("filer store etcd: %s", servers)
|
||||||
|
|
||||||
to, err := time.ParseDuration(timeout)
|
to, err := time.ParseDuration(timeout)
|
||||||
@ -55,6 +58,8 @@ func (store *EtcdStore) initialize(servers string, timeout string) (err error) {
|
|||||||
|
|
||||||
store.client, err = clientv3.New(clientv3.Config{
|
store.client, err = clientv3.New(clientv3.Config{
|
||||||
Endpoints: strings.Split(servers, ","),
|
Endpoints: strings.Split(servers, ","),
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
DialTimeout: to,
|
DialTimeout: to,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user