Laravel 7.x Shift (#11676)

* Shift bindings

PHP 5.5.9+ adds the new static `class` property which provides the fully qualified class name. This is preferred over using class name strings as these references are checked by the parser.

* Shift core files

* Shift to Throwable

* Shift Laravel dependencies
Add laravel/ui dependency
Use our fork of string-blade-compiler

* Shift config files

Default config files

In an effort to make upgrading the constantly changing config files
easier, Shift defaulted them so you can review the commit diff for
changes. Moving forward, you should use ENV variables or create a
separate config file to allow the core config files to remain
automatically upgradeable.

Restore config header comment

* Remove duplicate named routes

* add basic trust host middleware

* Trusted proxies should be default null

* Fix missed rename

* wip

* Rename routes

* Update trustedproxy.php

* Update Kernel.php

* revert trustedproxy.php

It only accepted '*' and not ['*']

* Fix tests

fake request was causing the error

Co-authored-by: Laravel Shift <shift@laravelshift.com>
Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Jellyfrog 2020-07-09 15:22:50 +02:00 committed by GitHub
parent e5bb6d80bc
commit f526ba326b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 971 additions and 632 deletions

View File

@ -124,7 +124,7 @@ class Laravel
public static function disableCliDebugOutput()
{
if (self::isBooted()) {
Log::setDefaultDriver('logfile');
Log::setDefaultDriver('stack');
}
}
@ -139,6 +139,11 @@ class Laravel
// set dummy path allows url helper to work and prevents full init again
$new_uri = ($auth ? '/dummy_legacy_auth' : '/dummy_legacy_unauth');
$request->server->set('REQUEST_URI', $new_uri);
// tests fail without this
if ($request->server->get('REMOTE_ADDR') === null) {
$request->server->set('REMOTE_ADDR', '127.0.0.1');
}
// set json type to prevent redirects in the dummy page
$request->server->set('HTTP_ACCEPT', 'dummy/json');

View File

@ -2,6 +2,7 @@
namespace App\Exceptions;
use Throwable;
use Exception;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
@ -35,7 +36,7 @@ class Handler extends ExceptionHandler
\LibreNMS\Exceptions\MaximumExecutionTimeExceeded::class,
];
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{
// If for some reason Blade hasn't been registered, try it now
try {
@ -59,7 +60,7 @@ class Handler extends ExceptionHandler
return parent::render($request, $exception);
}
protected function convertExceptionToArray(Exception $e)
protected function convertExceptionToArray(Throwable $e)
{
// override the non-debug error output to clue in user on how to debug
if (!config('app.debug') && !$this->isHttpException($e)) {

View File

@ -15,6 +15,7 @@ class Kernel extends HttpKernel
* @var array
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\HandleCors::class,
\App\Http\Middleware\CheckForMaintenanceMode::class,

View File

@ -0,0 +1,20 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Http\Middleware\TrustHosts as Middleware;
class TrustHosts extends Middleware
{
/**
* Get the host patterns that should be trusted.
*
* @return array
*/
public function hosts()
{
return [
$this->allSubdomainsOfApplicationUrl(),
];
}
}

View File

@ -10,7 +10,7 @@ class TrustProxies extends Middleware
/**
* The trusted proxies for this application.
*
* @var array|string
* @var array|string|null
*/
protected $proxies;

View File

@ -558,7 +558,7 @@ class Device extends BaseModel
public function muninPlugins()
{
return $this->hasMany('App\Models\MuninPlugin', 'device_id');
return $this->hasMany(\App\Models\MuninPlugin::class, 'device_id');
}
public function ospfInstances()

View File

@ -20,8 +20,14 @@
"issues": "https://github.com/librenms/librenms/issues/",
"irc": "irc://irc.freenode.org/#librenms"
},
"repositories": [
{
"type": "vcs",
"url": "git@github.com:librenms/StringBladeCompiler.git"
}
],
"require": {
"php": "^7.2",
"php": "^7.2.5",
"ext-curl": "*",
"ext-gd": "*",
"ext-json": "*",
@ -38,10 +44,9 @@
"easybook/geshi": "^1.0.8",
"ezyang/htmlpurifier": "^4.8",
"fico7489/laravel-pivot": "^3.0",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "^2.0",
"fideloper/proxy": "^4.2",
"influxdb/influxdb-php": "^1.14",
"laravel/framework": "^6.18",
"laravel/framework": "^7.11",
"laravel/tinker": "^2.0",
"librenms/laravel-vue-i18n-generator": "^0.1.46",
"oriceon/toastr-5-laravel": "dev-master",
@ -53,22 +58,25 @@
"symfony/yaml": "^4.0",
"tecnickcom/tcpdf": "~6.2.0",
"tightenco/ziggy": "^0.8.0",
"wpb/string-blade-compiler": "4.0.x-dev",
"xjtuwangke/passwordhash": "dev-master"
"wpb/string-blade-compiler": "dev-laravel-7-and-autoload-blade-custom-directives",
"xjtuwangke/passwordhash": "dev-master",
"laravel/ui": "^2.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.6",
"barryvdh/laravel-ide-helper": "^2.6.7",
"fzaninotto/faker": "^1.9.1",
"justinrainbow/json-schema": "^5.2",
"laravel/dusk": "^5.8",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0",
"laravel/dusk": "^5.9",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"php-parallel-lint/php-parallel-lint": "^1.1",
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^8.5",
"squizlabs/php_codesniffer": "^3.5",
"staudenmeir/dusk-updater": "^1.1",
"facade/ignition": "^1.4"
"facade/ignition": "^2.0"
},
"suggest": {
"ext-memcached": "Required if you utilize distributed polling",

1336
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,7 @@ return [
|
*/
'url' => env('APP_URL'),
'url' => env('APP_URL', 'http://localhost'),
'asset_url' => env('ASSET_URL', null),
@ -219,6 +219,7 @@ return [
'File' => Illuminate\Support\Facades\File::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Http' => Illuminate\Support\Facades\Http::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class,

View File

@ -49,6 +49,12 @@ return [
'provider' => 'legacy',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'token' => [
'driver' => 'token_driver',
'provider' => 'token_provider',
@ -79,6 +85,11 @@ return [
'model' => App\Models\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
'legacy' => [
'driver' => 'legacy',
'model' => App\Models\User::class,

View File

@ -47,6 +47,7 @@ return [
'array' => [
'driver' => 'array',
'serialize' => false,
],
'database' => [

View File

@ -69,9 +69,25 @@ return [
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'endpoint' => env('AWS_URL'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
],
],
/*
|--------------------------------------------------------------------------
| Symbolic Links
|--------------------------------------------------------------------------
|
| Here you may configure the symbolic links that will be created when the
| `storage:link` Artisan command is executed. The array keys should be
| the locations of the links and the values should be their targets.
|
*/
'links' => [
public_path('storage') => storage_path('app/public'),
],
];

View File

@ -25,7 +25,7 @@ return [
|
*/
'default' => env('LOG_CHANNEL', 'logfile'),
'default' => env('LOG_CHANNEL', 'stack'),
/*
|--------------------------------------------------------------------------
@ -43,7 +43,7 @@ return [
*/
'channels' => [
'logfile' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
'ignore_exceptions' => false,

View File

@ -1,6 +1,6 @@
<?php
/*
/*
| !!!! DO NOT EDIT THIS FILE !!!!
|
| You can change settings by setting them in the environment or .env
@ -12,45 +12,73 @@ return [
/*
|--------------------------------------------------------------------------
| Mail Driver
| Default Mailer
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
| This option controls the default mailer that is used to send any email
| messages sent by your application. Alternative mailers may be setup
| and used as needed; however, this mailer will be used by default.
|
*/
'default' => env('MAIL_MAILER', 'smtp'),
/*
|--------------------------------------------------------------------------
| Mailer Configurations
|--------------------------------------------------------------------------
|
| Here you may configure all of the mailers used by your application plus
| their respective settings. Several examples have been configured for
| you and you are free to add your own as your application requires.
|
| Laravel supports a variety of mail "transport" drivers to be used while
| sending an e-mail. You will specify which one you are using for your
| mailers below. You are free to add additional mailers as required.
|
| Supported: "smtp", "sendmail", "mailgun", "ses",
| "postmark", "log", "array"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
],
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'ses' => [
'transport' => 'ses',
],
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'mailgun' => [
'transport' => 'mailgun',
],
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'postmark' => [
'transport' => 'postmark',
],
'port' => env('MAIL_PORT', 587),
'sendmail' => [
'transport' => 'sendmail',
'path' => '/usr/sbin/sendmail -bs',
],
'log' => [
'transport' => 'log',
'channel' => env('MAIL_LOG_CHANNEL'),
],
'array' => [
'transport' => 'array',
],
],
/*
|--------------------------------------------------------------------------
@ -68,47 +96,6 @@ return [
'name' => env('MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
@ -128,17 +115,4 @@ return [
],
],
/*
|--------------------------------------------------------------------------
| Log Channel
|--------------------------------------------------------------------------
|
| If you are using the "log" driver, you may specify the logging channel
| if you prefer to keep mail messages separate from other log entries
| for simpler reading. Otherwise, the default channel will be used.
|
*/
'log_channel' => env('MAIL_LOG_CHANNEL'),
];

View File

@ -1,6 +1,6 @@
<?php
/*
/*
| !!!! DO NOT EDIT THIS FILE !!!!
|
| You can change settings by setting them in the environment or .env
@ -63,6 +63,7 @@ return [
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
'queue' => env('SQS_QUEUE', 'your-queue-name'),
'suffix' => env('SQS_SUFFIX'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
],

View File

@ -1,6 +1,6 @@
<?php
/*
/*
| !!!! DO NOT EDIT THIS FILE !!!!
|
| You can change settings by setting them in the environment or .env
@ -174,7 +174,7 @@ return [
|
*/
'secure' => env('SESSION_SECURE_COOKIE', false),
'secure' => env('SESSION_SECURE_COOKIE'),
/*
|--------------------------------------------------------------------------
@ -196,12 +196,12 @@ return [
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| do not enable this as other CSRF protection services are in place.
| will set this value to "lax" since this is a secure default value.
|
| Supported: "lax", "strict"
| Supported: "lax", "strict", "none", null
|
*/
'same_site' => null,
'same_site' => 'lax',
];

View File

@ -1,6 +1,6 @@
<?php
/*
/*
| !!!! DO NOT EDIT THIS FILE !!!!
|
| You can change settings by setting them in the environment or .env

View File

@ -36,7 +36,7 @@
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="testing"/>

View File

@ -34,7 +34,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
Route::get('routing/vrf/{id}', 'LegacyApiController@get_vrf')->name('get_vrf');
Route::get('routing/ipsec/data/{hostname}', 'LegacyApiController@list_ipsec')->name('list_ipsec');
Route::get('services', 'LegacyApiController@list_services')->name('list_services');
Route::get('services/{hostname}', 'LegacyApiController@list_services')->name('list_services');
Route::get('services/{hostname}', 'LegacyApiController@list_services')->name('list_services_device');
Route::group(['prefix' => 'resources'], function () {
Route::get('links/{id}', 'LegacyApiController@get_link')->name('get_link');
@ -92,7 +92,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
Route::get('{hostname}/graphs/health/{type}/{sensor_id?}', 'LegacyApiController@get_graph_generic_by_hostname')->name('get_health_graph');
Route::get('{hostname}/graphs/wireless/{type}/{sensor_id?}', 'LegacyApiController@get_graph_generic_by_hostname')->name('get_wireless_graph');
Route::get('{hostname}/vlans', 'LegacyApiController@get_vlans')->name('get_vlans');
Route::get('{hostname}/links', 'LegacyApiController@list_links')->name('list_links');
Route::get('{hostname}/links', 'LegacyApiController@list_links')->name('list_links_device');
Route::get('{hostname}/graphs', 'LegacyApiController@get_graphs')->name('get_graphs');
Route::get('{hostname}/fdb', 'LegacyApiController@get_fdb')->name('get_fdb');
Route::get('{hostname}/health/{type?}/{sensor_id?}', 'LegacyApiController@list_available_health_graphs')->name('list_available_health_graphs');
@ -101,7 +101,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
Route::get('{hostname}/ip', 'LegacyApiController@get_device_ip_addresses')->name('get_ip_addresses');
Route::get('{hostname}/port_stack', 'LegacyApiController@get_port_stack')->name('get_port_stack');
Route::get('{hostname}/components', 'LegacyApiController@get_components')->name('get_components');
Route::get('{hostname}/groups', 'LegacyApiController@get_device_groups')->name('get_device_groups');
Route::get('{hostname}/groups', 'LegacyApiController@get_device_groups')->name('get_device_groups_device');
// consumes the route below, but passes to it when detected
Route::get('{hostname}/ports/{ifname}', 'LegacyApiController@get_port_stats_by_port_hostname')->name('get_port_stats_by_port_hostname')->where('ifname', '.*');
Route::get('{hostname}/ports/{ifname}/{type}', 'LegacyApiController@get_graph_by_port_hostname')->name('get_graph_by_port_hostname');