diff --git a/src/Kong/Apis/Plugins/Jwt.php b/src/Kong/Apis/Plugins/Jwt.php new file mode 100644 index 0000000..3c6c19b --- /dev/null +++ b/src/Kong/Apis/Plugins/Jwt.php @@ -0,0 +1,77 @@ +url, $this->port); + + return $consumer->add($body, $headers); + } + + /** + * Create a new JWT credential for a consumer + * + * @see https://getkong.org/plugins/jwt/#create-a-jwt-credential + * + * @param string $identifier + * @param array $body + * @param array $headers + * + * @return array|\stdClass + */ + public function create($identifier, array $body = [], array $headers = []) + { + $this->setAllowedOptions(['key', 'algorithm', 'rsa_public_key', 'secret']); + $body = $this->createRequestBody($body); + + return $this->postRequest('consumers/' . $identifier . '/jwt', $body, $headers); + } + + /** + * Delete a JWT credential for a consumer + * + * @see https://getkong.org/plugins/jwt/#delete-a-jwt-credential + * + * @param string $identifier + * @param string $jwt_identifier + * @param array $headers + * + * @return array|\stdClass + */ + public function delete($identifier, $jwt_identifier, array $headers = []) + { + return $this->deleteRequest('consumers/' . $identifier . '/jwt/' . $jwt_identifier, $headers); + } + + /** + * List all JWT credentials for a consumer + * + * @see https://github.com/Mashape/getkong.org/issues/423 + * + * @param string $identifier + * @param array $params + * @param array $headers + * + * @return array|\stdClass + */ + public function list($identifier, array $params = [], array $headers = []) + { + return $this->getRequest('consumers/' . $identifier . '/jwt', $params, $headers); + } +} diff --git a/src/Kong/Apis/Plugins/JwtInterface.php b/src/Kong/Apis/Plugins/JwtInterface.php new file mode 100644 index 0000000..58e4325 --- /dev/null +++ b/src/Kong/Apis/Plugins/JwtInterface.php @@ -0,0 +1,11 @@ +url, $this->port); } + + /** + * Returns a new instance of the JWT plugin + * + * @return \TheRealGambo\Kong\Apis\Plugins\Jwt + */ + public function getPluginJwt() + { + return new Jwt($this->url, $this->port); + } }