Skip to content

Commit

Permalink
fix: fix APP_TRUST_PROXIES (#5955)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Saettler <alexis@saettler.org>
  • Loading branch information
asbiin authored Feb 6, 2022
1 parent 771ef78 commit e930afb
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function schedule(Schedule $schedule)
$this->scheduleCommand($schedule, 'monica:ping', 'daily');
$this->scheduleCommand($schedule, 'monica:clean', 'daily');
$this->scheduleCommand($schedule, 'monica:updategravatars', 'weekly');
if (config('monica.cloudflare')) {
if (config('app.cloudflare')) {
$this->scheduleCommand($schedule, 'cloudflare:reload', 'daily');
}
$this->scheduleCommand($schedule, 'model:prune', 'daily');
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
\Monicahq\Cloudflare\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
Expand Down
18 changes: 18 additions & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Http\Middleware;

use Monicahq\Cloudflare\Http\Middleware\TrustProxies as Middleware;

class TrustProxies extends Middleware
{
/**
* Get the trusted proxies.
*
* @return array|string|null
*/
protected function proxies()
{
return config('app.trust_proxies');
}
}
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function boot()
});

LaravelCloudflare::getProxiesUsing(function (): array {
return config('monica.cloudflare') ? CloudflareProxies::load() : [];
return config('app.cloudflare') ? CloudflareProxies::load() : [];
});
}

Expand Down
22 changes: 22 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@

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

/*
|--------------------------------------------------------------------------
| Trust proxies
|--------------------------------------------------------------------------
|
| List of trusted proxies.
| Example: set it to '*' to allow any proxy.
|
*/

'trust_proxies' => env('APP_TRUST_PROXIES'),

/*
|--------------------------------------------------------------------------
| Enable cloudflare trusted proxies
|--------------------------------------------------------------------------
|
| Enable to trust cloudflare proxies.
|
*/
'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false),

/*
|--------------------------------------------------------------------------
| Autoloaded Service Providers
Expand Down
8 changes: 0 additions & 8 deletions config/monica.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,4 @@
*/
'export_size' => (int) env('EXPORT_SIZE', 5),

/*
|--------------------------------------------------------------------------
| Enable cloudflare trusted proxies
|--------------------------------------------------------------------------
|
*/
'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false),

];

0 comments on commit e930afb

Please sign in to comment.