| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 4 | public function verify(Request $request, Collection $config): bool |
|
| 18 | { |
||
| 19 | 4 | $rawTimestamp = (string) $request->header('BOX-DELIVERY-TIMESTAMP'); |
|
| 20 | |||
| 21 | 4 | $timestamp = Carbon::parse($rawTimestamp); |
|
| 22 | |||
| 23 | // 10 Minute Tolerance |
||
| 24 | 4 | if (Carbon::now(config('app.timezone', 'UTC'))->diffInSeconds($timestamp) > $config->get('tolerance', 600)) { |
|
| 25 | 1 | return false; |
|
| 26 | } |
||
| 27 | |||
| 28 | 3 | $generated = $request->getContent() . $rawTimestamp; |
|
| 29 | |||
| 30 | // Primary or Secondary can pass to be valid. |
||
| 31 | 3 | return $this->check($generated, $config->get('primary'), $request->header('BOX-SIGNATURE-PRIMARY')) || $this->check($generated, $config->get('secondary'), $request->header('BOX-SIGNATURE-SECONDARY')); |
|
| 32 | } |
||
| 33 | |||
| 46 |