diff --git a/src/F5Purger.php b/src/F5Purger.php index a0388c5..d444541 100644 --- a/src/F5Purger.php +++ b/src/F5Purger.php @@ -44,6 +44,11 @@ class F5Purger extends BaseCachePurger */ public string $name = ''; + /** + * @var string + */ + public string $apiToken = ''; + /** * Whether to remove the content from the distribution, forcing the next request to retrieve the content from the origin server. With this off, the content will be replaced on the next request if the content is stale. * https://docs.cloud.f5.com/docs-v2/content-delivery-network/how-to/configure-cdn-distribution @@ -221,6 +226,7 @@ private function sendRequest(string $pattern): bool 'base_uri' => $this->baseUrl, 'headers' => [ 'Content-Type' => 'application/json', + 'Authorization' => 'APIToken ' . $this->apiToken, ], 'timeout' => self::API_REQUEST_TIMEOUT, ]); diff --git a/src/templates/settings.twig b/src/templates/settings.twig index c0d81b3..5005382 100644 --- a/src/templates/settings.twig +++ b/src/templates/settings.twig @@ -35,6 +35,18 @@ required: true, }) }} +{{ forms.autosuggestField({ + label: 'API Token'|t('blitz-f5'), + instructions: 'The API token.'|t('blitz-f5'), + placeholder: 'system', + suggestEnvVars: true, + suggestions: craft.cp.getEnvSuggestions(), + name: 'apiToken', + value: purger.apiToken, + errors: purger.getErrors('namespace'), + required: true, +}) }} + {{ forms.lightswitchField({ label: 'Hard Purge'|t('blitz-f5'), instructions: 'Whether to remove the content from the distribution, forcing the next request to retrieve the content from the origin server. With this off, the content will be replaced on the next request if the content is stale.'|t('blitz-f5'),