From 1d69341e88e2e363264d989d775d473d19897583 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Fri, 11 Dec 2020 19:09:32 +0100 Subject: [PATCH] swift: Add support for id based keystone v3 auth parameters This adds support for the following environment variables, which were previously missing: OS_USER_ID User ID for keystone v3 authentication OS_USER_DOMAIN_ID User domain ID for keystone v3 authentication OS_PROJECT_DOMAIN_ID Project domain ID for keystone v3 authentication OS_TRUST_ID Trust ID for keystone v3 authentication --- changelog/unreleased/issue-3147 | 11 +++++++++++ doc/030_preparing_a_new_repo.rst | 4 ++++ doc/040_backup.rst | 4 ++++ internal/backend/swift/config.go | 25 ++++++++++++++++--------- internal/backend/swift/swift.go | 3 +++ 5 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 changelog/unreleased/issue-3147 diff --git a/changelog/unreleased/issue-3147 b/changelog/unreleased/issue-3147 new file mode 100644 index 000000000..60f812fb5 --- /dev/null +++ b/changelog/unreleased/issue-3147 @@ -0,0 +1,11 @@ +Enhancement: Support further environment variables for swift authentication + +The swift backend now supports the following additional environment variables +to pass authentication details to restic: `OS_USER_ID`, `OS_USER_DOMAIN_ID`, +`OS_PROJECT_DOMAIN_ID` and `OS_TRUST_ID`. + +Depending on the openrc configuration file these might be required when the +user and project domains differ. + +https://github.com/restic/restic/issues/3147 +https://github.com/restic/restic/pull/3158 diff --git a/doc/030_preparing_a_new_repo.rst b/doc/030_preparing_a_new_repo.rst index 34b792ff3..d789068fb 100644 --- a/doc/030_preparing_a_new_repo.rst +++ b/doc/030_preparing_a_new_repo.rst @@ -375,10 +375,14 @@ the naming convention of those variables follows the official Python Swift clien $ export OS_AUTH_URL= $ export OS_REGION_NAME= $ export OS_USERNAME= + $ export OS_USER_ID= $ export OS_PASSWORD= $ export OS_USER_DOMAIN_NAME= + $ export OS_USER_DOMAIN_ID= $ export OS_PROJECT_NAME= $ export OS_PROJECT_DOMAIN_NAME= + $ export OS_PROJECT_DOMAIN_ID= + $ export OS_TRUST_ID= # For keystone v3 application credential authentication (application credential id) $ export OS_AUTH_URL= diff --git a/doc/040_backup.rst b/doc/040_backup.rst index f7d803576..182999781 100644 --- a/doc/040_backup.rst +++ b/doc/040_backup.rst @@ -466,13 +466,17 @@ environment variables. The following lists these environment variables: OS_AUTH_URL Auth URL for keystone authentication OS_REGION_NAME Region name for keystone authentication OS_USERNAME Username for keystone authentication + OS_USER_ID User ID for keystone v3 authentication OS_PASSWORD Password for keystone authentication OS_TENANT_ID Tenant ID for keystone v2 authentication OS_TENANT_NAME Tenant name for keystone v2 authentication OS_USER_DOMAIN_NAME User domain name for keystone authentication + OS_USER_DOMAIN_ID User domain ID for keystone v3 authentication OS_PROJECT_NAME Project name for keystone authentication OS_PROJECT_DOMAIN_NAME Project domain name for keystone authentication + OS_PROJECT_DOMAIN_ID Project domain ID for keystone v3 authentication + OS_TRUST_ID Trust ID for keystone v3 authentication OS_APPLICATION_CREDENTIAL_ID Application Credential ID (keystone v3) OS_APPLICATION_CREDENTIAL_NAME Application Credential Name (keystone v3) diff --git a/internal/backend/swift/config.go b/internal/backend/swift/config.go index 0ab4b656f..8ca26a918 100644 --- a/internal/backend/swift/config.go +++ b/internal/backend/swift/config.go @@ -10,15 +10,18 @@ import ( // Config contains basic configuration needed to specify swift location for a swift server type Config struct { - UserName string - Domain string - APIKey string - AuthURL string - Region string - Tenant string - TenantID string - TenantDomain string - TrustID string + UserName string + UserID string + Domain string + DomainID string + APIKey string + AuthURL string + Region string + Tenant string + TenantID string + TenantDomain string + TenantDomainID string + TrustID string StorageURL string AuthToken string @@ -88,9 +91,13 @@ func ApplyEnvironment(prefix string, cfg interface{}) error { {&c.AuthURL, prefix + "OS_AUTH_URL"}, // v3 specific + {&c.UserID, prefix + "OS_USER_ID"}, {&c.Domain, prefix + "OS_USER_DOMAIN_NAME"}, + {&c.DomainID, prefix + "OS_USER_DOMAIN_ID"}, {&c.Tenant, prefix + "OS_PROJECT_NAME"}, {&c.TenantDomain, prefix + "OS_PROJECT_DOMAIN_NAME"}, + {&c.TenantDomainID, prefix + "OS_PROJECT_DOMAIN_ID"}, + {&c.TrustID, prefix + "OS_TRUST_ID"}, // v2 specific {&c.TenantID, prefix + "OS_TENANT_ID"}, diff --git a/internal/backend/swift/swift.go b/internal/backend/swift/swift.go index ac626fe7b..fcbbec5e5 100644 --- a/internal/backend/swift/swift.go +++ b/internal/backend/swift/swift.go @@ -42,13 +42,16 @@ func Open(cfg Config, rt http.RoundTripper) (restic.Backend, error) { be := &beSwift{ conn: &swift.Connection{ UserName: cfg.UserName, + UserId: cfg.UserID, Domain: cfg.Domain, + DomainId: cfg.DomainID, ApiKey: cfg.APIKey, AuthUrl: cfg.AuthURL, Region: cfg.Region, Tenant: cfg.Tenant, TenantId: cfg.TenantID, TenantDomain: cfg.TenantDomain, + TenantDomainId: cfg.TenantDomainID, TrustId: cfg.TrustID, StorageUrl: cfg.StorageURL, AuthToken: cfg.AuthToken,