Skip to content

Commit 51e2411

Browse files
authored
Merge pull request #11 from portier/feat/php81
PHP 8.1 support
2 parents dc89cc2 + 5c99d66 commit 51e2411

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
php-versions: ['7.4', '8.0']
16+
php-versions: ['7.4', '8.0', '8.1']
1717
steps:
1818

1919
- name: Checkout

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
}
1616
},
1717
"require": {
18-
"fgrosse/phpasn1": "2.2",
18+
"fgrosse/phpasn1": "^2.2",
1919
"lcobucci/clock": "^2.0",
2020
"lcobucci/jwt": "^4.1",
2121
"guzzlehttp/guzzle": "^7.3"
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "^9.5",
25-
"phpstan/phpstan": "^0.12",
25+
"phpstan/phpstan": "^1.2.0",
2626
"squizlabs/php_codesniffer": "^3.6",
2727
"phpspec/prophecy-phpunit": "^2.0"
2828
}

src/Client.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,20 @@ public function verify(string $token): string
176176
throw new \Exception(sprintf('Token is missing claims: %s', implode(', ', $missing)));
177177
}
178178

179-
// Consume the nonce.
180179
$nonce = $claims->get('nonce');
181180
$email = $claims->get('email');
182181
$emailOriginal = $claims->get('email_original', $email);
182+
if (!is_string($nonce)) {
183+
throw new \Exception(sprintf('Token claim "nonce" is not a string'));
184+
}
185+
if (!is_string($email)) {
186+
throw new \Exception(sprintf('Token claim "email" is not a string'));
187+
}
188+
if (!is_string($emailOriginal)) {
189+
throw new \Exception(sprintf('Token claim "email_original" is not a string'));
190+
}
191+
192+
// Consume the nonce.
183193
$this->store->consumeNonce($nonce, $emailOriginal);
184194

185195
// Return the normalized email.

src/RedisStore.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ public function fetchCached(string $cacheId, string $url): \stdClass
2929

3030
$data = $this->redis->get($key);
3131
if ($data) {
32-
return json_decode($data);
32+
$data = json_decode($data);
33+
assert($data instanceof \stdClass);
34+
35+
return $data;
3336
}
3437

3538
$res = $this->fetch($url);

0 commit comments

Comments
 (0)