]> BookStack Code Mirror - bookstack/blob - app/Http/Middleware/TrustProxies.php
Updated the Swedish language files
[bookstack] / app / Http / Middleware / TrustProxies.php
1 <?php
2
3 namespace BookStack\Http\Middleware;
4
5 use Closure;
6 use Fideloper\Proxy\TrustProxies as Middleware;
7 use Illuminate\Http\Request;
8
9 class TrustProxies extends Middleware
10 {
11     /**
12      * The trusted proxies for this application.
13      *
14      * @var array
15      */
16     protected $proxies;
17
18     /**
19      * The current proxy header mappings.
20      *
21      * @var array
22      */
23     protected $headers = [
24         Request::HEADER_FORWARDED => 'FORWARDED',
25         Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
26         Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
27         Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
28         Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
29     ];
30
31     /**
32      * Handle the request, Set the correct user-configured proxy information.
33      * @param Request $request
34      * @param Closure $next
35      * @return mixed
36      */
37     public function handle($request, Closure $next)
38     {
39         $setProxies = config('app.proxies');
40         if ($setProxies !== '**' && $setProxies !== '*' && $setProxies !== '') {
41             $setProxies = explode(',', $setProxies);
42         }
43         $this->proxies = $setProxies;
44
45         return parent::handle($request, $next);
46     }
47 }