the browser-facing portion of osu!
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify proxy trusting logic

nanaya 31a6c8ef 60af4ead

+5 -29
-4
app/Http/Kernel.php
··· 5 5 6 6 namespace App\Http; 7 7 8 - use Fideloper\Proxy\TrustProxies; 9 8 use Illuminate\Foundation\Http\Kernel as HttpKernel; 10 9 11 10 class Kernel extends HttpKernel ··· 21 20 22 21 protected $middlewareGroups = [ 23 22 'api' => [ 24 - TrustProxies::class, 25 23 Middleware\AuthApi::class, 26 24 Middleware\SetLocale::class, 27 25 Middleware\CheckUserBanStatus::class, 28 26 ], 29 27 'web' => [ 30 - TrustProxies::class, 31 28 Middleware\StripCookies::class, 32 29 Middleware\EncryptCookies::class, 33 30 \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, ··· 43 40 Middleware\TurbolinksSupport::class, 44 41 ], 45 42 'lio' => [ 46 - TrustProxies::class, 47 43 Middleware\LegacyInterOpAuth::class, 48 44 ], 49 45 ];
+3
app/Providers/AppServiceProvider.php
··· 22 22 use App\Libraries\User\ScorePins; 23 23 use Datadog; 24 24 use Illuminate\Database\Eloquent\Relations\Relation; 25 + use Illuminate\Http\Request; 25 26 use Illuminate\Queue\Events\JobProcessed; 26 27 use Illuminate\Support\ServiceProvider; 27 28 use Laravel\Octane\Contracts\DispatchesTasks; ··· 76 77 $this->app->make('translator')->setSelector(new OsuMessageSelector()); 77 78 78 79 app('url')->forceScheme(substr(config('app.url'), 0, 5) === 'https' ? 'https' : 'http'); 80 + 81 + Request::setTrustedProxies(config('trustedproxy.proxies'), config('trustedproxy.headers')); 79 82 } 80 83 81 84 /**
+2 -25
config/trustedproxy.php
··· 2 2 3 3 use Illuminate\Http\Request; 4 4 5 - $trustedProxies = presence(env('TRUSTED_PROXIES')); 6 - if ($trustedProxies !== null && $trustedProxies !== '*') { 7 - $trustedProxies = explode(',', $trustedProxies); 8 - } 9 - 10 5 return [ 11 6 12 7 /* ··· 15 10 * Both IPv4 and IPv6 addresses are 16 11 * supported, along with CIDR notation. 17 12 * 18 - * The "*" character is syntactic sugar 19 - * within TrustedProxy to trust any proxy 20 - * that connects directly to your server, 21 - * a requirement when you cannot know the address 22 - * of your proxy (e.g. if using ELB or similar). 23 - * 13 + * Use "0.0.0.0/0,::/0" to trust any proxy. 24 14 */ 25 - 'proxies' => $trustedProxies, 26 - 27 - /* 28 - * To trust one or more specific proxies that connect 29 - * directly to your server, use an array or a string separated by comma of IP addresses: 30 - */ 31 - // 'proxies' => ['192.168.1.1'], 32 - // 'proxies' => '192.168.1.1, 192.168.1.2', 33 - 34 - /* 35 - * Or, to trust all proxies that connect 36 - * directly to your server, use a "*" 37 - */ 38 - // 'proxies' => '*', 15 + 'proxies' => explode(',', presence(env('TRUSTED_PROXIES')) ?? ''), 39 16 40 17 /* 41 18 * Which headers to use to detect proxy related data (For, Host, Proto, Port)