|
12 | 12 | use DateTimeZone; |
13 | 13 | use Lcobucci\Clock\SystemClock; |
14 | 14 | use Lcobucci\JWT\Configuration; |
15 | | -use Lcobucci\JWT\Encoding\CannotDecodeContent; |
16 | 15 | use Lcobucci\JWT\Signer\Key\InMemory; |
17 | 16 | use Lcobucci\JWT\Signer\Key\LocalFileReference; |
18 | 17 | use Lcobucci\JWT\Signer\Rsa\Sha256; |
19 | | -use Lcobucci\JWT\Token\InvalidTokenStructure; |
20 | | -use Lcobucci\JWT\Token\UnsupportedHeaderFound; |
21 | 18 | use Lcobucci\JWT\Validation\Constraint\SignedWith; |
22 | 19 | use Lcobucci\JWT\Validation\Constraint\ValidAt; |
23 | 20 | use Lcobucci\JWT\Validation\RequiredConstraintsViolated; |
@@ -95,18 +92,18 @@ public function validateAuthorization(ServerRequestInterface $request) |
95 | 92 | $jwt = \trim((string) \preg_replace('/^(?:\s+)?Bearer\s/', '', $header[0])); |
96 | 93 |
|
97 | 94 | try { |
98 | | - // Attempt to parse and validate the JWT |
| 95 | + // Attempt to parse the JWT |
99 | 96 | $token = $this->jwtConfiguration->parser()->parse($jwt); |
| 97 | + } catch (\Lcobucci\JWT\Exception $exception) { |
| 98 | + throw OAuthServerException::accessDenied($exception->getMessage(), null, $exception); |
| 99 | + } |
100 | 100 |
|
| 101 | + try { |
| 102 | + // Attempt to validate the JWT |
101 | 103 | $constraints = $this->jwtConfiguration->validationConstraints(); |
102 | | - |
103 | | - try { |
104 | | - $this->jwtConfiguration->validator()->assert($token, ...$constraints); |
105 | | - } catch (RequiredConstraintsViolated $exception) { |
106 | | - throw OAuthServerException::accessDenied('Access token could not be verified'); |
107 | | - } |
108 | | - } catch (CannotDecodeContent | InvalidTokenStructure | UnsupportedHeaderFound $exception) { |
109 | | - throw OAuthServerException::accessDenied($exception->getMessage(), null, $exception); |
| 104 | + $this->jwtConfiguration->validator()->assert($token, ...$constraints); |
| 105 | + } catch (RequiredConstraintsViolated $exception) { |
| 106 | + throw OAuthServerException::accessDenied('Access token could not be verified'); |
110 | 107 | } |
111 | 108 |
|
112 | 109 | $claims = $token->claims(); |
|
0 commit comments