1 | <?php |
||
15 | class BearerTokenValidator implements IntrospectionValidatorInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var AccessTokenRepositoryInterface |
||
19 | */ |
||
20 | private $accessTokenRepository; |
||
21 | |||
22 | /** |
||
23 | * @var \League\OAuth2\Server\CryptKey |
||
24 | */ |
||
25 | protected $privateKey; |
||
26 | |||
27 | /** |
||
28 | * @param AccessTokenRepositoryInterface $accessTokenRepository |
||
29 | */ |
||
30 | 4 | public function __construct(AccessTokenRepositoryInterface $accessTokenRepository) |
|
34 | |||
35 | /** |
||
36 | * Set the public key |
||
37 | * |
||
38 | * @param \League\OAuth2\Server\CryptKey $key |
||
39 | */ |
||
40 | 2 | public function setPrivateKey(CryptKey $key) |
|
44 | |||
45 | /** |
||
46 | * Validates the given token from the request |
||
47 | * |
||
48 | * @param ServerRequestInterface $request |
||
49 | * @return bool |
||
50 | */ |
||
51 | 5 | public function validateIntrospection(ServerRequestInterface $request) |
|
69 | |||
70 | /** |
||
71 | * Gets the token from the request body. |
||
72 | * |
||
73 | * @param ServerRequestInterface $request |
||
74 | * @return Token |
||
75 | */ |
||
76 | public function getTokenFromRequest(ServerRequestInterface $request) |
||
83 | |||
84 | /** |
||
85 | * Validate the JWT token. |
||
86 | * |
||
87 | * @param Token $token |
||
88 | * |
||
89 | * @return bool |
||
90 | */ |
||
91 | 2 | private function isTokenUnverified(Token $token) |
|
102 | |||
103 | /** |
||
104 | * Ensure access token hasn't expired |
||
105 | * |
||
106 | * @param Token $token |
||
107 | * |
||
108 | * @return bool |
||
109 | */ |
||
110 | 3 | private function isTokenExpired(Token $token) |
|
116 | |||
117 | /** |
||
118 | * Check if the given token is revoked. |
||
119 | * |
||
120 | * @param Token $token |
||
121 | * |
||
122 | * @return bool |
||
123 | */ |
||
124 | 4 | private function isTokenRevoked(Token $token) |
|
128 | } |
||
129 |