Completed
Push — master ( dd33b3...946b97 )
by Lyal
19:36 queued 17:10
created

Webhook   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
1
<?php
2
namespace Lyal\Checkr\Laravel\Http\Middleware;
3
4
5
use Closure;
6
use Illuminate\Support\Facades\Log;
7
8
class Webhook
9
{
10
    public function handle($request, Closure $next)
11
    {
12
        if (stripos($request->header('User-Agent'), 'Checkr-Webhook') === false) {
13
            Log::alert('Invalid user agent for Checkr webhook');
14
            abort(404);
0 ignored issues
show
Bug introduced by
The function abort was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

14
            /** @scrutinizer ignore-call */ 
15
            abort(404);
Loading history...
15
        }
16
17
        if (hash_hmac('SHA256', $request->getContent(), env('checkr_api_key')) !== $request->header('X-Checkr-Signature')) {
18
            Log::alert('Checkr signature does not match request.');
19
            abort(404);
20
        }
21
22
        return $next($request);
23
    }
24
}