Skip to content

Commit

Permalink
Cloudflare issue 3148588: Valid key is rejected as too long.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lio Novelli committed Nov 19, 2020
1 parent d116b20 commit 764eaa0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ApiEndpoints/CloudFlareAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function makeRequest($request_type, $api_end_point, $request_params =
// This check seems superfluous. However, the Api only returns a http 400
// code. This proactive check gives us more information.
$api_key_length = strlen($this->apikey);
$is_api_key_valid = $api_key_length == CloudFlareAPI::API_KEY_LENGTH || $api_key_length == CloudflareAPI::GLOBAL_API_KEY_LENGTH;
$is_api_key_valid = $api_key_length == self:API_KEY_LENGTH || $api_key_length == self::GLOBAL_API_KEY_LENGTH;
$is_api_key_alpha_numeric = ctype_alnum($this->apikey);
$is_api_key_lower_case = !(preg_match('/[A-Z]/', $this->apikey));

Expand All @@ -156,7 +156,7 @@ protected function makeRequest($request_type, $api_end_point, $request_params =
throw new CloudFlareInvalidCredentialException('Invalid Api Key: Key can only contain alphanumeric characters.', 403);
}

if (!$is_api_key_lower_case) {
if ($api_key_length == self::GLOBAL_API_KEY_LENGTH && !$is_api_key_lower_case) {
throw new CloudFlareInvalidCredentialException('Invalid Api Key: Key can only contain lowercase or numerical characters.', 403);
}

Expand Down

0 comments on commit 764eaa0

Please sign in to comment.