now favicons
This commit is contained in:
@@ -18,11 +18,22 @@ class VerifyInternalApiSignature
|
||||
$signature = (string) $request->header('X-WMS-Signature');
|
||||
|
||||
abort_if($secret === '' || $timestamp === '' || $signature === '', 401);
|
||||
abort_if(strtotime($timestamp) === false, 401, 'Invalid internal API timestamp.');
|
||||
abort_if(abs(now()->timestamp - strtotime($timestamp)) > 300, 401, 'Expired internal API signature.');
|
||||
|
||||
$expected = hash_hmac('sha256', $timestamp . '.' . $request->getContent(), $secret);
|
||||
abort_unless(hash_equals($expected, $signature), 401, 'Invalid internal API signature.');
|
||||
$body = $request->getContent();
|
||||
$payloads = array_unique([
|
||||
$timestamp . '.' . $body,
|
||||
$timestamp . '.',
|
||||
$timestamp . '.[]',
|
||||
]);
|
||||
|
||||
return $next($request);
|
||||
foreach ($payloads as $payload) {
|
||||
if (hash_equals(hash_hmac('sha256', $payload, $secret), $signature)) {
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
abort(401, 'Invalid internal API signature.');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user