Tony Murray 5c76890373 Add @signedGraphTag() and @signedGraphUrl() blade directives (#14269)
* More secure external graph access
Add @signedGraphTag() and @signedGraphUrl() blade directives
Takes either an array of graph variables or a url to a graph
Uses a signed url that is accessible without user login, embeds signature in url to authenticate access
See Laravel Signed Url for more details.
Adds Laravel route to graphs (does not change links to use it yet)
@graphImage requires the other PR
Also APP_URL is required in .env

* missing files from rebase

* Fix url parsing with a get string

* allow width and height to be omitted

* Documentation

* Add to, otherwise it will always be now

* Doc note for to and from relative security

* fix vars.inc.php (Laravel has a dummy url here)
2022-09-03 12:48:43 -05:00

39 lines
843 B
PHP

<?php
/**
* LibreNMS
*
* This file is part of LibreNMS.
*
* @copyright (C) 2006 - 2012 Adam Armstrong
*/
use LibreNMS\Data\Store\Datastore;
use LibreNMS\Util\Debug;
$auth = false;
$start = microtime(true);
$init_modules = ['web', 'auth'];
require realpath(__DIR__ . '/..') . '/includes/init.php';
if (! Auth::check()) {
// check for unauthenticated graphs and set auth
$auth = is_client_authorized($_SERVER['REMOTE_ADDR']);
if (! $auth) {
exit('Unauthorized');
}
}
Debug::set(isset($_GET['debug']));
require \LibreNMS\Config::get('install_dir') . '/includes/html/graphs/graph.inc.php';
Datastore::terminate();
if (Debug::isEnabled()) {
echo '<br />';
printf('Runtime %.3fs', microtime(true) - $start);
echo '<br />';
app(\App\Polling\Measure\MeasurementManager::class)->printStats();
}