Swift: introduce application credential auth support
This commit is contained in:
parent
38c0018906
commit
34baf05d9d
3 changed files with 83 additions and 39 deletions
2
Makefile
2
Makefile
|
@ -67,7 +67,7 @@ ifdef FULL_TESTS
|
||||||
go vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf ./...
|
go vet $(BUILDTAGS) -printfuncs Debugf,Infof,Logf,Errorf ./...
|
||||||
errcheck $(BUILDTAGS) ./...
|
errcheck $(BUILDTAGS) ./...
|
||||||
find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1
|
find . -name \*.go | grep -v /vendor/ | xargs goimports -d | grep . ; test $$? -eq 1
|
||||||
go list ./... | xargs -n1 golint | grep -E -v '(StorageUrl|CdnUrl)' ; test $$? -eq 1
|
go list ./... | xargs -n1 golint | grep -E -v '(StorageUrl|CdnUrl|ApplicationCredentialId)' ; test $$? -eq 1
|
||||||
else
|
else
|
||||||
@echo Skipping source quality tests as version of go too old
|
@echo Skipping source quality tests as version of go too old
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -130,6 +130,15 @@ func init() {
|
||||||
}, {
|
}, {
|
||||||
Name: "auth_token",
|
Name: "auth_token",
|
||||||
Help: "Auth Token from alternate authentication - optional (OS_AUTH_TOKEN)",
|
Help: "Auth Token from alternate authentication - optional (OS_AUTH_TOKEN)",
|
||||||
|
}, {
|
||||||
|
Name: "application_credential_id",
|
||||||
|
Help: "Application Credential ID (OS_APPLICATION_CREDENTIAL_ID)",
|
||||||
|
}, {
|
||||||
|
Name: "application_credential_name",
|
||||||
|
Help: "Application Credential Name (OS_APPLICATION_CREDENTIAL_NAME)",
|
||||||
|
}, {
|
||||||
|
Name: "application_credential_secret",
|
||||||
|
Help: "Application Credential Secret (OS_APPLICATION_CREDENTIAL_SECRET)",
|
||||||
}, {
|
}, {
|
||||||
Name: "auth_version",
|
Name: "auth_version",
|
||||||
Help: "AuthVersion - optional - set to (1,2,3) if your auth URL has no version (ST_AUTH_VERSION)",
|
Help: "AuthVersion - optional - set to (1,2,3) if your auth URL has no version (ST_AUTH_VERSION)",
|
||||||
|
@ -186,6 +195,9 @@ type Options struct {
|
||||||
StorageURL string `config:"storage_url"`
|
StorageURL string `config:"storage_url"`
|
||||||
AuthToken string `config:"auth_token"`
|
AuthToken string `config:"auth_token"`
|
||||||
AuthVersion int `config:"auth_version"`
|
AuthVersion int `config:"auth_version"`
|
||||||
|
ApplicationCredentialId string `config:"application_credential_id"`
|
||||||
|
ApplicationCredentialName string `config:"application_credential_name"`
|
||||||
|
ApplicationCredentialSecret string `config:"application_credential_secret"`
|
||||||
StoragePolicy string `config:"storage_policy"`
|
StoragePolicy string `config:"storage_policy"`
|
||||||
EndpointType string `config:"endpoint_type"`
|
EndpointType string `config:"endpoint_type"`
|
||||||
ChunkSize fs.SizeSuffix `config:"chunk_size"`
|
ChunkSize fs.SizeSuffix `config:"chunk_size"`
|
||||||
|
@ -305,6 +317,9 @@ func swiftConnection(opt *Options, name string) (*swift.Connection, error) {
|
||||||
StorageUrl: opt.StorageURL,
|
StorageUrl: opt.StorageURL,
|
||||||
AuthToken: opt.AuthToken,
|
AuthToken: opt.AuthToken,
|
||||||
AuthVersion: opt.AuthVersion,
|
AuthVersion: opt.AuthVersion,
|
||||||
|
ApplicationCredentialId: opt.ApplicationCredentialId,
|
||||||
|
ApplicationCredentialName: opt.ApplicationCredentialName,
|
||||||
|
ApplicationCredentialSecret: opt.ApplicationCredentialSecret,
|
||||||
EndpointType: swift.EndpointType(opt.EndpointType),
|
EndpointType: swift.EndpointType(opt.EndpointType),
|
||||||
ConnectTimeout: 10 * fs.Config.ConnectTimeout, // Use the timeouts in the transport
|
ConnectTimeout: 10 * fs.Config.ConnectTimeout, // Use the timeouts in the transport
|
||||||
Timeout: 10 * fs.Config.Timeout, // Use the timeouts in the transport
|
Timeout: 10 * fs.Config.Timeout, // Use the timeouts in the transport
|
||||||
|
@ -318,12 +333,14 @@ func swiftConnection(opt *Options, name string) (*swift.Connection, error) {
|
||||||
}
|
}
|
||||||
StorageUrl, AuthToken := c.StorageUrl, c.AuthToken // nolint
|
StorageUrl, AuthToken := c.StorageUrl, c.AuthToken // nolint
|
||||||
if !c.Authenticated() {
|
if !c.Authenticated() {
|
||||||
|
if (c.ApplicationCredentialId != "" || c.ApplicationCredentialName != "") && c.ApplicationCredentialSecret == "" {
|
||||||
if c.UserName == "" && c.UserId == "" {
|
if c.UserName == "" && c.UserId == "" {
|
||||||
return nil, errors.New("user name or user id not found for authentication (and no storage_url+auth_token is provided)")
|
return nil, errors.New("user name or user id not found for authentication (and no storage_url+auth_token is provided)")
|
||||||
}
|
}
|
||||||
if c.ApiKey == "" {
|
if c.ApiKey == "" {
|
||||||
return nil, errors.New("key not found")
|
return nil, errors.New("key not found")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if c.AuthUrl == "" {
|
if c.AuthUrl == "" {
|
||||||
return nil, errors.New("auth not found")
|
return nil, errors.New("auth not found")
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,33 @@ User ID to log in - optional - most swift systems use user and leave this blank
|
||||||
- Type: string
|
- Type: string
|
||||||
- Default: ""
|
- Default: ""
|
||||||
|
|
||||||
|
#### --swift-application-credential-id
|
||||||
|
|
||||||
|
Application Credential ID to log in - optional (v3 auth) (OS_APPLICATION_CREDENTIAL_ID).
|
||||||
|
|
||||||
|
- Config: application_credential_id
|
||||||
|
- Env Var: RCLONE_SWIFT_APPLICATION_CREDENTIAL_ID
|
||||||
|
- Type: string
|
||||||
|
- Default: ""
|
||||||
|
|
||||||
|
#### --swift-application-credential-name
|
||||||
|
|
||||||
|
Application Credential name to log in - optional (v3 auth) (OS_APPLICATION_CREDENTIAL_NAME).
|
||||||
|
|
||||||
|
- Config: application_credential_name
|
||||||
|
- Env Var: RCLONE_SWIFT_APPLICATION_CREDENTIAL_NAME
|
||||||
|
- Type: string
|
||||||
|
- Default: ""
|
||||||
|
|
||||||
|
#### --swift-application-credential-secret
|
||||||
|
|
||||||
|
Application Credential secret to log in - optional (v3 auth) (OS_APPLICATION_CREDENTIAL_SECRET).
|
||||||
|
|
||||||
|
- Config: application_credential_secret
|
||||||
|
- Env Var: RCLONE_SWIFT_APPLICATION_CREDENTIAL_SECRET
|
||||||
|
- Type: string
|
||||||
|
- Default: ""
|
||||||
|
|
||||||
#### --swift-domain
|
#### --swift-domain
|
||||||
|
|
||||||
User domain - optional (v3 auth) (OS_USER_DOMAIN_NAME)
|
User domain - optional (v3 auth) (OS_USER_DOMAIN_NAME)
|
||||||
|
|
Loading…
Add table
Reference in a new issue