mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 08:17:32 -05: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();
 | 
						|
    }
 | 
						|
}
 |