Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
8 | class JwtValidator { |
||
9 | |||
10 | /** |
||
11 | * Will fetch and cache JWT keys |
||
12 | * @var JwtKeysFetcher |
||
13 | */ |
||
14 | protected $keyFetcher; |
||
15 | |||
16 | /** |
||
17 | * A map of valid Issuer->Audience pairs |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $validIssAud; |
||
21 | |||
22 | public function __construct(JwtKeysFetcher $keyFetcher, array $validIssAud) { |
||
23 | $this->keyFetcher = $keyFetcher; |
||
24 | $this->validIssAud = $validIssAud; |
||
25 | } |
||
26 | |||
27 | public function signatureIsValid(Token $token) { |
||
28 | $kid = $token->getHeader("kid"); |
||
29 | $alg = $token->getHeader("alg"); |
||
30 | $publicKey = $this->keyFetcher->getByKID($kid); |
||
31 | |||
32 | switch ($alg) { |
||
33 | case "RS256": |
||
34 | $signer = new Sha256(); |
||
35 | break; |
||
36 | default: |
||
37 | $signer = new Sha256(); |
||
38 | break; |
||
39 | } |
||
40 | |||
41 | $signatureIsValid = $token->verify($signer, $publicKey); |
||
42 | return $signatureIsValid; |
||
43 | } |
||
44 | |||
45 | public function isExpired(Token $token) { |
||
47 | } |
||
48 | |||
49 | public function claimsAreValid(Token $token) { |
||
56 |