Skip to content

Commit

Permalink
Merge pull request #11 from portier/feat/php81
Browse files Browse the repository at this point in the history
PHP 8.1 support
  • Loading branch information
stephank authored Dec 21, 2021
2 parents dc89cc2 + 5c99d66 commit 51e2411
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0']
php-versions: ['7.4', '8.0', '8.1']
steps:

- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
}
},
"require": {
"fgrosse/phpasn1": "2.2",
"fgrosse/phpasn1": "^2.2",
"lcobucci/clock": "^2.0",
"lcobucci/jwt": "^4.1",
"guzzlehttp/guzzle": "^7.3"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^1.2.0",
"squizlabs/php_codesniffer": "^3.6",
"phpspec/prophecy-phpunit": "^2.0"
}
Expand Down
12 changes: 11 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,20 @@ public function verify(string $token): string
throw new \Exception(sprintf('Token is missing claims: %s', implode(', ', $missing)));
}

// Consume the nonce.
$nonce = $claims->get('nonce');
$email = $claims->get('email');
$emailOriginal = $claims->get('email_original', $email);
if (!is_string($nonce)) {
throw new \Exception(sprintf('Token claim "nonce" is not a string'));
}
if (!is_string($email)) {
throw new \Exception(sprintf('Token claim "email" is not a string'));
}
if (!is_string($emailOriginal)) {
throw new \Exception(sprintf('Token claim "email_original" is not a string'));
}

// Consume the nonce.
$this->store->consumeNonce($nonce, $emailOriginal);

// Return the normalized email.
Expand Down
5 changes: 4 additions & 1 deletion src/RedisStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function fetchCached(string $cacheId, string $url): \stdClass

$data = $this->redis->get($key);
if ($data) {
return json_decode($data);
$data = json_decode($data);
assert($data instanceof \stdClass);

return $data;
}

$res = $this->fetch($url);
Expand Down

0 comments on commit 51e2411

Please sign in to comment.