Add token authentication to Swift remote
This commit is contained in:
parent
a45d2e5289
commit
2627e4bd8d
|
@ -39,6 +39,7 @@ type SwiftClient struct {
|
||||||
tenantname string
|
tenantname string
|
||||||
userid string
|
userid string
|
||||||
username string
|
username string
|
||||||
|
token string
|
||||||
archive bool
|
archive bool
|
||||||
archivepath string
|
archivepath string
|
||||||
expireSecs int
|
expireSecs int
|
||||||
|
@ -76,14 +77,21 @@ func (c *SwiftClient) validateConfig(conf map[string]string) (err error) {
|
||||||
}
|
}
|
||||||
c.userid = userID
|
c.userid = userID
|
||||||
|
|
||||||
|
token, ok := conf["token"]
|
||||||
|
if !ok {
|
||||||
|
token = os.Getenv("OS_AUTH_TOKEN")
|
||||||
|
}
|
||||||
|
c.token = token
|
||||||
|
|
||||||
password, ok := conf["password"]
|
password, ok := conf["password"]
|
||||||
if !ok {
|
if !ok {
|
||||||
password = os.Getenv("OS_PASSWORD")
|
password = os.Getenv("OS_PASSWORD")
|
||||||
if password == "" {
|
|
||||||
return fmt.Errorf("missing 'password' configuration or OS_PASSWORD environment variable")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.password = password
|
c.password = password
|
||||||
|
if password == "" && token == "" {
|
||||||
|
return fmt.Errorf("missing either password or token configuration or OS_PASSWORD or OS_AUTH_TOKEN environment variable")
|
||||||
|
}
|
||||||
|
|
||||||
region, ok := conf["region_name"]
|
region, ok := conf["region_name"]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -203,6 +211,7 @@ func (c *SwiftClient) validateConfig(conf map[string]string) (err error) {
|
||||||
TenantID: c.tenantid,
|
TenantID: c.tenantid,
|
||||||
TenantName: c.tenantname,
|
TenantName: c.tenantname,
|
||||||
Password: c.password,
|
Password: c.password,
|
||||||
|
TokenID: c.token,
|
||||||
DomainID: c.domainid,
|
DomainID: c.domainid,
|
||||||
DomainName: c.domainname,
|
DomainName: c.domainname,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue