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