2016-01-08 09:01:21 -06:00
|
|
|
<?php
|
2017-10-21 01:40:00 -05:00
|
|
|
/**
|
|
|
|
* Kernel.php
|
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
|
|
|
*
|
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 07:41:58 -06:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-21 01:40:00 -05:00
|
|
|
*/
|
2017-09-14 10:40:02 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-01-08 09:01:21 -06:00
|
|
|
namespace FireflyIII\Http;
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2017-09-10 01:33:51 -05:00
|
|
|
use FireflyIII\Http\Middleware\Authenticate;
|
|
|
|
use FireflyIII\Http\Middleware\AuthenticateTwoFactor;
|
|
|
|
use FireflyIII\Http\Middleware\Binder;
|
|
|
|
use FireflyIII\Http\Middleware\EncryptCookies;
|
|
|
|
use FireflyIII\Http\Middleware\IsAdmin;
|
|
|
|
use FireflyIII\Http\Middleware\Range;
|
|
|
|
use FireflyIII\Http\Middleware\RedirectIfAuthenticated;
|
|
|
|
use FireflyIII\Http\Middleware\RedirectIfTwoFactorAuthenticated;
|
|
|
|
use FireflyIII\Http\Middleware\Sandstorm;
|
2017-10-27 11:56:38 -05:00
|
|
|
use FireflyIII\Http\Middleware\StartFireflySession;
|
2017-09-10 01:33:51 -05:00
|
|
|
use FireflyIII\Http\Middleware\TrimStrings;
|
|
|
|
use FireflyIII\Http\Middleware\TrustProxies;
|
|
|
|
use FireflyIII\Http\Middleware\VerifyCsrfToken;
|
|
|
|
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
|
|
|
|
use Illuminate\Auth\Middleware\Authorize;
|
|
|
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
2015-02-05 21:39:52 -06:00
|
|
|
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
2017-09-10 01:33:51 -05:00
|
|
|
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;
|
|
|
|
|
2017-12-17 07:30:53 -06:00
|
|
|
/**
|
2017-12-23 10:42:07 -06:00
|
|
|
* @CodeCoverageIgnore
|
2017-12-17 07:30:53 -06:00
|
|
|
* Class Kernel
|
|
|
|
*/
|
2015-02-06 12:33:31 -06:00
|
|
|
class Kernel extends HttpKernel
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The application's global HTTP middleware stack.
|
|
|
|
*
|
2016-01-08 09:01:21 -06:00
|
|
|
* These middleware are run during every request to your application.
|
|
|
|
*
|
2015-02-06 12:33:31 -06:00
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-10 01:33:51 -05:00
|
|
|
protected $middleware
|
|
|
|
= [
|
|
|
|
CheckForMaintenanceMode::class,
|
|
|
|
ValidatePostSize::class,
|
|
|
|
TrimStrings::class,
|
|
|
|
ConvertEmptyStringsToNull::class,
|
|
|
|
TrustProxies::class,
|
|
|
|
];
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2015-02-06 12:33:31 -06:00
|
|
|
/**
|
2016-01-08 09:01:21 -06:00
|
|
|
* The application's route middleware groups.
|
2015-02-06 12:33:31 -06:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-10 01:33:51 -05:00
|
|
|
protected $middlewareGroups
|
|
|
|
= [
|
|
|
|
// does not check login
|
|
|
|
// does not check 2fa
|
|
|
|
// does not check activation
|
|
|
|
'web' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
],
|
|
|
|
|
|
|
|
// MUST NOT be logged in. Does not care about 2FA or confirmation.
|
|
|
|
'user-not-logged-in' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
|
|
|
Binder::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
RedirectIfAuthenticated::class,
|
|
|
|
],
|
|
|
|
// MUST be logged in.
|
|
|
|
// MUST NOT have 2FA
|
|
|
|
// don't care about confirmation:
|
|
|
|
'user-logged-in-no-2fa' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
|
|
|
Binder::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
Authenticate::class,
|
|
|
|
RedirectIfTwoFactorAuthenticated::class,
|
|
|
|
],
|
|
|
|
|
|
|
|
// MUST be logged in
|
|
|
|
// don't care about 2fa
|
|
|
|
// don't care about confirmation.
|
|
|
|
'user-simple-auth' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
|
|
|
Binder::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
Authenticate::class,
|
|
|
|
],
|
|
|
|
|
|
|
|
// MUST be logged in
|
|
|
|
// MUST have 2fa
|
|
|
|
// MUST be confirmed.
|
|
|
|
// (this group includes the other Firefly middleware)
|
|
|
|
'user-full-auth' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
Authenticate::class,
|
|
|
|
AuthenticateTwoFactor::class,
|
|
|
|
Range::class,
|
|
|
|
Binder::class,
|
|
|
|
],
|
|
|
|
// MUST be logged in
|
|
|
|
// MUST have 2fa
|
|
|
|
// MUST be confirmed.
|
|
|
|
// MUST have owner role
|
|
|
|
// (this group includes the other Firefly middleware)
|
|
|
|
'admin' => [
|
|
|
|
Sandstorm::class,
|
|
|
|
EncryptCookies::class,
|
|
|
|
AddQueuedCookiesToResponse::class,
|
2017-10-27 11:56:38 -05:00
|
|
|
StartFireflySession::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
ShareErrorsFromSession::class,
|
|
|
|
VerifyCsrfToken::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
//SubstituteBindings::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
Authenticate::class,
|
|
|
|
AuthenticateTwoFactor::class,
|
|
|
|
IsAdmin::class,
|
|
|
|
Range::class,
|
|
|
|
Binder::class,
|
|
|
|
],
|
|
|
|
|
|
|
|
'api' => [
|
|
|
|
'throttle:60,1',
|
|
|
|
'bindings',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2016-01-08 09:01:21 -06:00
|
|
|
/**
|
|
|
|
* The application's route middleware.
|
|
|
|
*
|
|
|
|
* These middleware may be assigned to groups or used individually.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-10 01:33:51 -05:00
|
|
|
protected $routeMiddleware
|
|
|
|
= [
|
|
|
|
'auth' => Authenticate::class,
|
|
|
|
'auth.basic' => AuthenticateWithBasicAuth::class,
|
2017-12-25 01:45:23 -06:00
|
|
|
'bindings' => Binder::class,
|
2017-09-10 01:33:51 -05:00
|
|
|
'can' => Authorize::class,
|
|
|
|
'guest' => RedirectIfAuthenticated::class,
|
|
|
|
'throttle' => ThrottleRequests::class,
|
|
|
|
];
|
2015-02-05 21:39:52 -06:00
|
|
|
}
|