Work around issue with Weathermaps (#10033)

This commit is contained in:
Tony Murray
2019-03-27 16:34:24 -05:00
committed by GitHub
parent 7bfe0bc831
commit 4e4ceffc0a
3 changed files with 29 additions and 1 deletions

View File

@@ -46,6 +46,25 @@ class Laravel
$kernel->bootstrap();
}
public static function bootWeb()
{
// this is not a substitute for the normal Laravel boot, just a way to make auth work for external php
if (self::isBooted()) {
return;
}
define('LARAVEL_START', microtime(true));
$install_dir = realpath(__DIR__ . '/../..');
$app = require_once $install_dir . '/bootstrap/app.php';
$kernel = $app->make(\Illuminate\Contracts\Http\Kernel::class);
$request = \Illuminate\Http\Request::capture();
$request->server->set('REQUEST_URI', '/blank'); // load an empty page since it will be discarded
$response = $kernel->handle($request);
// $response->send(); // don't send response, legacy code will
}
public static function isBooted()
{
return !empty(app()->isAlias('Illuminate\Foundation\Application')) && app()->isBooted();

View File

@@ -93,7 +93,11 @@ if (module_selected('alerts', $init_modules)) {
}
// Boot Laravel
\LibreNMS\Util\Laravel::bootCli();
if (module_selected('auth', $init_modules)) {
\LibreNMS\Util\Laravel::bootWeb();
} else {
\LibreNMS\Util\Laravel::bootCli();
}
set_debug(false); // disable debug initially (hides legacy errors too)

View File

@@ -106,6 +106,11 @@ Route::group(['middleware' => ['auth', '2fa'], 'guard' => 'auth'], function () {
// demo helper
Route::permanentRedirect('demo', '/');
// blank page, dummy page for external code using Laravel::bootWeb()
Route::any('/blank', function () {
return '';
});
// Legacy routes
Route::any('/{path?}', 'LegacyController@index')
->where('path', '^((?!_debugbar).)*');