Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix APP_TRUST_PROXIES #5955

Merged
merged 1 commit into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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),

];