mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
*
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
*
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
|
*
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
*/
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Illuminate\Routing\Exceptions\InvalidSignatureException;
|
|
|
|
class ValidateSignature
|
|
{
|
|
/**
|
|
* The names of the parameters that should be ignored.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $ignore = [
|
|
'q'
|
|
];
|
|
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @param string|null $relative
|
|
* @return \Illuminate\Http\Response
|
|
*
|
|
* @throws \Illuminate\Routing\Exceptions\InvalidSignatureException
|
|
*/
|
|
public function handle($request, Closure $next, $relative = null)
|
|
{
|
|
$ignore = property_exists($this, 'except') ? $this->except : $this->ignore;
|
|
|
|
if ($request->hasValidSignatureWhileIgnoring($ignore, $relative !== 'relative')) {
|
|
return $next($request);
|
|
}
|
|
|
|
throw new InvalidSignatureException();
|
|
}
|
|
}
|