Swift v3 requires setting a scope

Unscoped auth is not guaranteed to return a catalog. So require the
scope to be set properly.

See https://developer.openstack.org/api-ref/identity/v3/index.html#password-authentication-with-unscoped-authorization

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-04-23 19:32:41 +02:00
parent 000f41ba01
commit ba71918ad2
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 13 additions and 1 deletions

View File

@ -1235,10 +1235,18 @@ $CONFIG = array(
'name' => 'default', 'name' => 'default',
], ],
], ],
'scope' => [
'project' => [
'name' => 'service',
'domain' => [
'name' => 'default',
],
],
],
'tenantName' => 'service', 'tenantName' => 'service',
'serviceName' => 'swift', 'serviceName' => 'swift',
'region' => 'regionOne', 'region' => 'regionOne',
'url' => "http://yourswifthost:5000/v3", 'url' => 'http://yourswifthost:5000/v3',
'bucket' => 'nextcloud', 'bucket' => 'nextcloud',
], ],
], ],

View File

@ -108,6 +108,10 @@ class SwiftFactory {
]); ]);
if (isset($this->params['user']) && isset($this->params['user']['name'])) { if (isset($this->params['user']) && isset($this->params['user']['name'])) {
if (!isset($this->params['scope'])) {
throw new StorageAuthException('Scope has to be defined for V3 requests');
}
return $this->auth(IdentityV3Service::factory($httpClient), $cacheKey); return $this->auth(IdentityV3Service::factory($httpClient), $cacheKey);
} else { } else {
return $this->auth(IdentityV2Service::factory($httpClient), $cacheKey); return $this->auth(IdentityV2Service::factory($httpClient), $cacheKey);