Skip to content

Commit

Permalink
Laravel 6.x (librenms#11397)
Browse files Browse the repository at this point in the history
* Update Laravel core files

Fix app/Http/Kernel.php

* Use RouteServiceProvider::HOME

* Sync Laravel default config files

* Update composer dependencies to Laravel 6

* fix resources/lang/en/validation.php

* Manually fixing tests

required by travis, fails locally???

* Update wpb/string-blade-compiler

* Add new viewany() authorization policies

* Update minimum PHP version to 7.2

* Re-generate our json test-dumps

Due to:
laravel/framework#16069
laravel/framework#31100

* update truenas data

* fix truenas

Co-authored-by: Laravel Shift <[email protected]>
Co-authored-by: Tony Murray <[email protected]>
  • Loading branch information
3 people authored May 23, 2020
1 parent b3f78ec commit b09bc07
Show file tree
Hide file tree
Showing 293 changed files with 51,914 additions and 43,302 deletions.
4 changes: 2 additions & 2 deletions app/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class Checks
public static function preAutoload()
{
// Check PHP version otherwise it will just say server error
if (version_compare('7.1.3', PHP_VERSION, '>=')) {
if (version_compare('7.2.5', PHP_VERSION, '>=')) {
self::printMessage(
'PHP version 7.1.3 or newer is required to run LibreNMS',
'PHP version 7.2.5 or newer is required to run LibreNMS',
null,
true
);
Expand Down
40 changes: 40 additions & 0 deletions app/Http/Controllers/Auth/ConfirmPasswordController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ConfirmsPasswords;

class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/

use ConfirmsPasswords;

/**
* Where to redirect users when the intended url fails.
*
* @var string
*/
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
}
10 changes: 0 additions & 10 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,4 @@ class ForgotPasswordController extends Controller
*/

use SendsPasswordResetEmails;

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Controllers\Controller;
use App\Models\Device;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use LibreNMS\Config;

Expand All @@ -27,7 +28,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/';
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers\Auth;

use App\Providers\RouteServiceProvider;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
Expand All @@ -28,7 +29,7 @@ class RegisterController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand Down
13 changes: 2 additions & 11 deletions app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\ResetsPasswords;

class ResetPasswordController extends Controller
Expand All @@ -25,15 +26,5 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';

/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
protected $redirectTo = RouteServiceProvider::HOME;
}
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/VerificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Auth\VerifiesEmails;

class VerificationController extends Controller
Expand All @@ -25,7 +26,7 @@ class VerificationController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = RouteServiceProvider::HOME;

/**
* Create a new controller instance.
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Fideloper\Proxy\TrustProxies::class,
];

/**
Expand Down Expand Up @@ -47,7 +47,7 @@ class Kernel extends HttpKernel
],

'api' => [
'bindings',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
'auth:token',
\Spatie\Cors\Cors::class,
],
Expand All @@ -61,14 +61,15 @@ class Kernel extends HttpKernel
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth' => \App\Http\Middleware\Authenticate::class,
'2fa' => \App\Http\Middleware\VerifyTwoFactor::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'deny-demo' => \App\Http\Middleware\DenyDemoUser::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
Expand All @@ -84,7 +85,8 @@ class Kernel extends HttpKernel
protected $middlewarePriority = [
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\Illuminate\Auth\Middleware\Authenticate::class,
\App\Http\Middleware\Authenticate::class,
\Illuminate\Routing\Middleware\ThrottleRequests::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Illuminate\Auth\Middleware\Authorize::class,
Expand Down
21 changes: 21 additions & 0 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
17 changes: 17 additions & 0 deletions app/Http/Middleware/CheckForMaintenanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;

class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
3 changes: 2 additions & 1 deletion app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;

Expand All @@ -18,7 +19,7 @@ class RedirectIfAuthenticated
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/');
return redirect(RouteServiceProvider::HOME);
}

return $next($request);
Expand Down
23 changes: 23 additions & 0 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;

/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}
11 changes: 11 additions & 0 deletions app/Policies/DeviceGroupPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public function view(User $user, DeviceGroup $deviceGroup)
return false;
}

/**
* Determine whether the user can view any device group.
*
* @param \App\User $user
* @return mixed
*/
public function viewAny(User $user)
{
return false;
}

/**
* Determine whether the user can create device groups.
*
Expand Down
12 changes: 12 additions & 0 deletions app/Policies/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ public function view(User $user, User $target)
return $user->isAdmin() || $target->is($user);
}

/**
* Determine whether the user can view any user.
*
* @param \App\User $user
* @return mixed
*/
public function viewAny(User $user)
{
return $user->isAdmin();
}


/**
* Determine whether the user can create users.
*
Expand Down
7 changes: 7 additions & 0 deletions app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class RouteServiceProvider extends ServiceProvider
*/
protected $namespace = 'App\Http\Controllers';

/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/';

/**
* Define your route model bindings, pattern filters, etc.
*
Expand Down
45 changes: 0 additions & 45 deletions app/Providers/ViewServiceProvider.php

This file was deleted.

Loading

0 comments on commit b09bc07

Please sign in to comment.