1 | <?php |
||
21 | class TokenHelper |
||
22 | { |
||
23 | /** |
||
24 | * The CSRF claim identifier |
||
25 | */ |
||
26 | const CLAIM_CSRF = 'csrf'; |
||
27 | |||
28 | /** |
||
29 | * The Audience claim identifier |
||
30 | */ |
||
31 | const CLAIM_AUDIENCE = 'aud'; |
||
32 | |||
33 | /** |
||
34 | * The Issuer claim identifier |
||
35 | */ |
||
36 | const CLAIM_ISSUER = 'iss'; |
||
37 | |||
38 | /** |
||
39 | * The Identity claim identifier |
||
40 | */ |
||
41 | const CLAIM_IDENTITY = 'jti'; |
||
42 | |||
43 | /** |
||
44 | * @param $token |
||
45 | * @param bool $validate |
||
46 | * @return Token|null |
||
47 | * @throws \craft\errors\SiteNotFoundException |
||
48 | */ |
||
49 | public static function parse(string $token, bool $validate = true) |
||
67 | |||
68 | /** |
||
69 | * @param IdentityInterface $identity |
||
70 | * @return string |
||
71 | */ |
||
72 | public static function getSignatureKey(IdentityInterface $identity = null) |
||
82 | |||
83 | /** |
||
84 | * @param Token $token |
||
85 | * @return bool |
||
86 | */ |
||
87 | public static function verifyTokenCsrfClaim(Token $token): bool |
||
100 | |||
101 | /** |
||
102 | * @param Token $token |
||
103 | * @param IdentityInterface $identity |
||
104 | * @return bool |
||
105 | */ |
||
106 | public static function verifyTokenSignature(Token $token, IdentityInterface $identity = null): bool |
||
125 | |||
126 | /** |
||
127 | * @param Token $token |
||
128 | * @return bool |
||
129 | * @throws \craft\errors\SiteNotFoundException |
||
130 | */ |
||
131 | public static function verifyAudience(Token $token): bool |
||
144 | |||
145 | /** |
||
146 | * Verify that the issuer is one we can accept from |
||
147 | * |
||
148 | * @param Token $token |
||
149 | * @param array $issuers |
||
150 | * @return bool |
||
151 | * @throws \craft\errors\SiteNotFoundException |
||
152 | */ |
||
153 | public static function verifyIssuer(Token $token, array $issuers): bool |
||
169 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: