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