Skip to content

Firefly III: a personal finances manager

Clean up kernel files and middleware.

James Cole5ed4e7aa796f
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
deleted file mode 100644
index f60ba1b4f7..0000000000
--- a/app/Console/Kernel.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-/**
- * Kernel.php
- * Copyright (c) 2020 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace FireflyIII\Console;
-
-use Illuminate\Console\Scheduling\Schedule;
-use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
-use Illuminate\Support\Facades\Log;
-use Override;
-
-/**
- * File to make sure commands work.
- */
-class Kernel extends ConsoleKernel
-{
- /**
- * Register the commands for the application.
- */
- #[Override]
- protected function commands(): void
- {
- $this->load(__DIR__.'/Commands');
-
- require base_path('routes/console.php');
- }
-
- /**
- * Define the application's command schedule.
- */
- #[Override]
- protected function schedule(Schedule $schedule): void
- {
- $schedule->call(static function (): void {
- Log::error('Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://docs.firefly-iii.org/');
- echo "\n";
- echo '------------';
- echo "\n";
- echo wordwrap('Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions here:');
- echo "\n";
- echo 'https://docs.firefly-iii.org/';
- echo "\n\n";
- echo 'Disable this cron job!';
- echo "\n";
- echo '------------';
- echo "\n";
- })->daily();
- }
-}
diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php
deleted file mode 100644
index 3b002cf5a2..0000000000
--- a/app/Http/Kernel.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-/**
- * Kernel.php
- * Copyright (c) 2019 [email protected]
- *
- * This file is part of Firefly III (https://github.com/firefly-iii).
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-declare(strict_types=1);
-
-namespace FireflyIII\Http;
-
-use FireflyIII\Http\Middleware\Authenticate;
-use FireflyIII\Http\Middleware\Binder;
-use FireflyIII\Http\Middleware\InstallationId;
-use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
-use FireflyIII\Http\Middleware\StartFireflySession;
-use FireflyIII\Http\Middleware\TrimStrings;
-use FireflyIII\Http\Middleware\TrustProxies;
-use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
-use Illuminate\Auth\Middleware\Authorize;
-use Illuminate\Foundation\Http\Kernel as HttpKernel;
-use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
-use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
-use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
-use Illuminate\Routing\Middleware\ThrottleRequests;
-use Illuminate\View\Middleware\ShareErrorsFromSession;
-
-/**
- * Class Kernel
- */
-class Kernel extends HttpKernel
-{
- protected $middleware = [
- // SecureHeaders::class,
- CheckForMaintenanceMode::class,
- ValidatePostSize::class,
- TrimStrings::class,
- ConvertEmptyStringsToNull::class,
- TrustProxies::class,
- InstallationId::class,
- ];
- protected $middlewareAliases = [
- 'auth' => Authenticate::class,
- 'auth.basic' => AuthenticateWithBasicAuth::class,
- 'bindings' => Binder::class,
- 'can' => Authorize::class,
- 'guest' => RedirectIfAuthenticated::class,
- 'throttle' => ThrottleRequests::class,
- ];
- protected $middlewarePriority = [StartFireflySession::class, ShareErrorsFromSession::class, Authenticate::class, Binder::class, Authorize::class];
-}
diff --git a/app/Http/Middleware/StartFireflySession.php b/app/Http/Middleware/StartFireflyIIISession.php
similarity index 96%
rename from app/Http/Middleware/StartFireflySession.php
rename to app/Http/Middleware/StartFireflyIIISession.php
index 823702bffd..df98bcd036 100644
--- a/app/Http/Middleware/StartFireflySession.php
+++ b/app/Http/Middleware/StartFireflyIIISession.php
@@ -32,7 +32,7 @@ use Override;
/**
* Class StartFireflySession.
*/
-class StartFireflySession extends StartSession
+class StartFireflyIIISession extends StartSession
{
/**
* Store the current URL for the request if necessary.
diff --git a/app/Providers/FireflySessionProvider.php b/app/Providers/FireflySessionProvider.php
index 2e9eb7e1a9..81789aa918 100644
--- a/app/Providers/FireflySessionProvider.php
+++ b/app/Providers/FireflySessionProvider.php
@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Providers;
-use FireflyIII\Http\Middleware\StartFireflySession;
+use FireflyIII\Http\Middleware\StartFireflyIIISession;
use Illuminate\Session\SessionManager;
use Illuminate\Support\ServiceProvider;
use Override;
@@ -43,7 +43,7 @@ class FireflySessionProvider extends ServiceProvider
$this->registerSessionDriver();
- $this->app->singleton(StartFireflySession::class);
+ $this->app->singleton(StartFireflyIIISession::class);
}
/**
diff --git a/app/Providers/SessionServiceProvider.php b/app/Providers/SessionServiceProvider.php
index 2fdf356bd3..de68cb8665 100644
--- a/app/Providers/SessionServiceProvider.php
+++ b/app/Providers/SessionServiceProvider.php
@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Providers;
-use FireflyIII\Http\Middleware\StartFireflySession;
+use FireflyIII\Http\Middleware\StartFireflyIIISession;
use Illuminate\Session\SessionServiceProvider as BaseSessionServiceProvider;
use Override;
@@ -42,6 +42,6 @@ class SessionServiceProvider extends BaseSessionServiceProvider
$this->registerSessionDriver();
- $this->app->singleton(StartFireflySession::class);
+ $this->app->singleton(StartFireflyIIISession::class);
}
}
diff --git a/bootstrap/app.php b/bootstrap/app.php
index 51dbacdc7a..d853215949 100644
--- a/bootstrap/app.php
+++ b/bootstrap/app.php
@@ -32,7 +32,7 @@ use FireflyIII\Http\Middleware\IsAdmin;
use FireflyIII\Http\Middleware\Range;
use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
use FireflyIII\Http\Middleware\SecureHeaders;
-use FireflyIII\Http\Middleware\StartFireflySession;
+use FireflyIII\Http\Middleware\StartFireflyIIISession;
use FireflyIII\Http\Middleware\TrustProxies;
use FireflyIII\Http\Middleware\VerifyCsrfToken;
use Illuminate\Contracts\Debug\ExceptionHandler;
@@ -96,18 +96,19 @@ $app = Application::configure(basePath: dirname(__DIR__))
health : '/health',
)
->withMiddleware(function (Middleware $middleware): void {
+
// overrule the standard middleware
$middleware->use(
[
- InvokeDeferredCallbacks::class,
- HandleCors::class,
- PreventRequestsDuringMaintenance::class,
- ValidatePostSize::class,
- TrimStrings::class,
- ConvertEmptyStringsToNull::class,
- SecureHeaders::class,
- TrustProxies::class,
- ]
+ InvokeDeferredCallbacks::class,
+ \Illuminate\Http\Middleware\TrustProxies::class, // use the DEFAULT middleware for this.
+ HandleCors::class,
+ PreventRequestsDuringMaintenance::class,
+ ValidatePostSize::class,
+ TrimStrings::class,
+ ConvertEmptyStringsToNull::class,
+ SecureHeaders::class, // is a Firefly III specific middleware class.
+ ]
);
// overrule the web group
@@ -115,7 +116,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
[
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
@@ -136,7 +137,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
Installer::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
Binder::class,
@@ -148,7 +149,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
Installer::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
Binder::class,
@@ -159,7 +160,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
$middleware->appendToGroup('user-simple-auth', [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
Binder::class,
@@ -170,7 +171,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
$middleware->appendToGroup('user-full-auth', [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
Authenticate::class,
@@ -185,7 +186,7 @@ $app = Application::configure(basePath: dirname(__DIR__))
$middleware->appendToGroup('admin', [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
- StartFireflySession::class,
+ StartFireflyIIISession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
Authenticate::class,
@@ -225,16 +226,6 @@ $app = Application::configure(basePath: dirname(__DIR__))
|
*/
-$app->singleton(
- Kernel::class,
- FireflyIII\Http\Kernel::class
-);
-
-$app->singleton(
- Illuminate\Contracts\Console\Kernel::class,
- FireflyIII\Console\Kernel::class
-);
-
$app->singleton(
ExceptionHandler::class,
Handler::class