diff --git a/src/Identity/v3/Api.php b/src/Identity/v3/Api.php index 325e3ac1..f2d84cd9 100644 --- a/src/Identity/v3/Api.php +++ b/src/Identity/v3/Api.php @@ -19,10 +19,11 @@ public function postTokens(): array 'method' => 'POST', 'path' => 'auth/tokens', 'params' => [ - 'methods' => $this->params->methods(), - 'user' => $this->params->user(), - 'tokenId' => $this->params->tokenBody(), - 'scope' => $this->params->scope(), + 'methods' => $this->params->methods(), + 'user' => $this->params->user(), + 'application_credential' => $this->params->applicationCredential(), + 'tokenId' => $this->params->tokenBody(), + 'scope' => $this->params->scope(), ], ]; } diff --git a/src/Identity/v3/Models/Token.php b/src/Identity/v3/Models/Token.php index 935f409f..f8b8ab39 100644 --- a/src/Identity/v3/Models/Token.php +++ b/src/Identity/v3/Models/Token.php @@ -115,7 +115,17 @@ public function create(array $data): Creatable .'provide domain information.' ); } - } elseif (isset($data['tokenId'])) { + } + elseif (isset($data['application_credential'])) { + $data['methods'] = ['application_credential']; + if (!isset($data['application_credential']['id']) || !isset($data['application_credential']['secret'])) { + throw new \InvalidArgumentException( + 'When authenticating with a application_credential, you must provide application credential ID ' + .' and application credential secret.' + ); + } + } + elseif (isset($data['tokenId'])) { $data['methods'] = ['token']; } else { throw new \InvalidArgumentException('Either a user or token must be provided.'); diff --git a/src/Identity/v3/Params.php b/src/Identity/v3/Params.php index f001d3c4..2fa01ff8 100644 --- a/src/Identity/v3/Params.php +++ b/src/Identity/v3/Params.php @@ -21,6 +21,23 @@ public function methods(): array ]; } + public function applicationCredential(): array { + return [ + 'type' => self::OBJECT_TYPE, + 'path' => 'auth.identity', + 'properties' => [ + 'id' => [ + 'type' => self::STRING_TYPE, + 'description' => $this->id('application credential id'), + ], + 'secret' => [ + 'type' => self::STRING_TYPE, + 'description' => 'The secret of the application credential', + ], + ], + ]; + } + public function user(): array { return [ diff --git a/src/ObjectStore/v1/Models/StorageObject.php b/src/ObjectStore/v1/Models/StorageObject.php index a4016d2d..2ddfa4c7 100644 --- a/src/ObjectStore/v1/Models/StorageObject.php +++ b/src/ObjectStore/v1/Models/StorageObject.php @@ -208,7 +208,7 @@ public function resetMetadata(array $metadata) public function getMetadata(): array { $response = $this->executeWithState($this->api->headObject()); - + $this->populateFromResponse($response); return $this->parseMetadata($response); } }