2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
2018-10-15 07:00:48 +02:00
|
|
|
use Fideloper\Proxy\TrustProxies as Middleware;
|
2020-10-01 01:32:27 +02:00
|
|
|
use Illuminate\Contracts\Config\Repository;
|
2020-11-25 15:19:52 +01:00
|
|
|
use Illuminate\Http\Request;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
|
|
|
class TrustProxies extends Middleware
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The trusted proxies for this application.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $proxies;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The headers that should be used to detect proxies.
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
|
|
|
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
2020-10-01 01:32:27 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Instantiate trusted proxies middleware
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Contracts\Config\Repository $config
|
|
|
|
*/
|
2020-11-25 15:19:52 +01:00
|
|
|
public function __construct(Repository $config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
2020-10-01 01:32:27 +02:00
|
|
|
|
2020-11-25 15:19:52 +01:00
|
|
|
if (config('ninja.trusted_proxies')) {
|
|
|
|
$this->proxies = config('ninja.trusted_proxies');
|
|
|
|
}
|
2020-10-01 01:32:27 +02:00
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|