Skip to content

Commit e930afb

Browse files
authored
fix: fix APP_TRUST_PROXIES (#5955)
Signed-off-by: Alexis Saettler <[email protected]>
1 parent 771ef78 commit e930afb

File tree

6 files changed

+43
-11
lines changed

6 files changed

+43
-11
lines changed

app/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function schedule(Schedule $schedule)
5050
$this->scheduleCommand($schedule, 'monica:ping', 'daily');
5151
$this->scheduleCommand($schedule, 'monica:clean', 'daily');
5252
$this->scheduleCommand($schedule, 'monica:updategravatars', 'weekly');
53-
if (config('monica.cloudflare')) {
53+
if (config('app.cloudflare')) {
5454
$this->scheduleCommand($schedule, 'cloudflare:reload', 'daily');
5555
}
5656
$this->scheduleCommand($schedule, 'model:prune', 'daily');

app/Http/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Kernel extends HttpKernel
1414
* @var array
1515
*/
1616
protected $middleware = [
17-
\Monicahq\Cloudflare\Http\Middleware\TrustProxies::class,
17+
\App\Http\Middleware\TrustProxies::class,
1818
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
1919
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
2020
\App\Http\Middleware\TrimStrings::class,

app/Http/Middleware/TrustProxies.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Monicahq\Cloudflare\Http\Middleware\TrustProxies as Middleware;
6+
7+
class TrustProxies extends Middleware
8+
{
9+
/**
10+
* Get the trusted proxies.
11+
*
12+
* @return array|string|null
13+
*/
14+
protected function proxies()
15+
{
16+
return config('app.trust_proxies');
17+
}
18+
}

app/Providers/AppServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function boot()
114114
});
115115

116116
LaravelCloudflare::getProxiesUsing(function (): array {
117-
return config('monica.cloudflare') ? CloudflareProxies::load() : [];
117+
return config('app.cloudflare') ? CloudflareProxies::load() : [];
118118
});
119119
}
120120

config/app.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,28 @@
139139

140140
'password_rules' => env('APP_PASSWORD_RULES', 'mixedCase,letters,numbers,symbols,uncompromised'),
141141

142+
/*
143+
|--------------------------------------------------------------------------
144+
| Trust proxies
145+
|--------------------------------------------------------------------------
146+
|
147+
| List of trusted proxies.
148+
| Example: set it to '*' to allow any proxy.
149+
|
150+
*/
151+
152+
'trust_proxies' => env('APP_TRUST_PROXIES'),
153+
154+
/*
155+
|--------------------------------------------------------------------------
156+
| Enable cloudflare trusted proxies
157+
|--------------------------------------------------------------------------
158+
|
159+
| Enable to trust cloudflare proxies.
160+
|
161+
*/
162+
'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false),
163+
142164
/*
143165
|--------------------------------------------------------------------------
144166
| Autoloaded Service Providers

config/monica.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,4 @@
284284
*/
285285
'export_size' => (int) env('EXPORT_SIZE', 5),
286286

287-
/*
288-
|--------------------------------------------------------------------------
289-
| Enable cloudflare trusted proxies
290-
|--------------------------------------------------------------------------
291-
|
292-
*/
293-
'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false),
294-
295287
];

0 commit comments

Comments
 (0)