Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function validate(string $privateKey, Token $token, ServerRequestInterface $request) : bool |
||
24 | { |
||
25 | $method = $request->getMethod(); |
||
26 | $uri = (string)$request->getUri(); |
||
27 | $base64 = base64_encode((string)$request->getBody()); |
||
28 | $data = "{$privateKey}{$method}{$uri}{$token->getTimeStamp()}{$token->getNonce()}{$base64}"; |
||
29 | |||
30 | if (hash('sha256', $data) !== $token->getSignature()) { |
||
31 | throw new AuthenticationException(401, 'Invalid Hash'); |
||
32 | } |
||
33 | |||
34 | return true; |
||
35 | } |
||
36 | } |
||
37 |