mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove legacy auth usage of $_SESSION (#10491)
* Remove auth use of $_SESSION Will break plugins that depend on $_SESSION, Weathermap was already fixed. Port them to use Auth::check()/Auth::user()/Auth:id() * revert accidental replacement
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
namespace LibreNMS\Alert;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use App\Models\User;
|
||||
use LibreNMS\Config;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
|
||||
@@ -85,7 +85,7 @@ class AlertUtil
|
||||
$email = Config::get('alert.default_mail', Config::get('alerts.email.default'));
|
||||
return $email ? [$email => ''] : [];
|
||||
}
|
||||
$users = LegacyAuth::get()->getUserlist();
|
||||
$users = User::query()->thisAuth()->get();
|
||||
$contacts = array();
|
||||
$uids = array();
|
||||
foreach ($results as $result) {
|
||||
@@ -126,9 +126,6 @@ class AlertUtil
|
||||
if (empty($user['realname'])) {
|
||||
$user['realname'] = $user['username'];
|
||||
}
|
||||
if (empty($user['level'])) {
|
||||
$user['level'] = LegacyAuth::get()->getUserlevel($user['username']);
|
||||
}
|
||||
if (Config::get('alert.globals') && ( $user['level'] >= 5 && $user['level'] < 10 )) {
|
||||
$contacts[$user['email']] = $user['realname'];
|
||||
} elseif (Config::get('alert.admins') && $user['level'] == 10) {
|
||||
|
@@ -74,51 +74,11 @@ class LegacyAuth
|
||||
return static::get();
|
||||
}
|
||||
|
||||
public static function check()
|
||||
{
|
||||
self::checkInitSession();
|
||||
return isset($_SESSION['authenticated']) && $_SESSION['authenticated'];
|
||||
}
|
||||
|
||||
public static function user()
|
||||
{
|
||||
self::checkInitSession();
|
||||
return new UserProxy();
|
||||
}
|
||||
|
||||
public static function id()
|
||||
{
|
||||
self::checkInitSession();
|
||||
return isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0;
|
||||
}
|
||||
|
||||
protected static function checkInitSession()
|
||||
public static function setUpLegacySession()
|
||||
{
|
||||
if (!isset($_SESSION)) {
|
||||
@session_start();
|
||||
session_write_close();
|
||||
}
|
||||
}
|
||||
|
||||
public static function setUpLegacySession()
|
||||
{
|
||||
if (Auth::check()) {
|
||||
$user = Auth::user();
|
||||
|
||||
@session_start();
|
||||
$_SESSION['username'] = $user->username;
|
||||
|
||||
// set up legacy variables, but don't override existing ones (ad anonymous bind can only get user_id at login)
|
||||
if (!isset($_SESSION['userlevel'])) {
|
||||
$_SESSION['userlevel'] = $user->level;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
$_SESSION['user_id'] = $user->user_id;
|
||||
}
|
||||
|
||||
$_SESSION['authenticated'] = true;
|
||||
session_write_close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,72 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* UserProxy.php
|
||||
*
|
||||
* This pretends to be a User class like Laravel
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2018 Tony Murray
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Authentication;
|
||||
|
||||
/**
|
||||
* @property int level
|
||||
* @property string username
|
||||
* @property int user_id
|
||||
*/
|
||||
class UserProxy
|
||||
{
|
||||
public function hasGlobalAdmin()
|
||||
{
|
||||
return $_SESSION['userlevel'] >= 10;
|
||||
}
|
||||
|
||||
public function hasGlobalRead()
|
||||
{
|
||||
return $_SESSION['userlevel'] >= 5;
|
||||
}
|
||||
|
||||
// public function hasDeviceAdmin()
|
||||
// {
|
||||
// return $_SESSION['userlevel'] >= 7;
|
||||
// }
|
||||
|
||||
public function isAdmin()
|
||||
{
|
||||
return $_SESSION['userlevel'] == 10;
|
||||
}
|
||||
|
||||
public function isDemoUser()
|
||||
{
|
||||
return $_SESSION['userlevel'] == 11;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
if ($name == 'level') {
|
||||
return $_SESSION['userlevel'];
|
||||
} elseif ($name == 'username') {
|
||||
return $_SESSION['username'];
|
||||
} elseif ($name == 'user_id') {
|
||||
return $_SESSION['user_id'];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -6,7 +6,6 @@ use App\Models\User;
|
||||
use DB;
|
||||
use Illuminate\Auth\Events\Login;
|
||||
use Illuminate\Auth\Events\Logout;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use Request;
|
||||
use Toastr;
|
||||
|
||||
@@ -36,9 +35,6 @@ class AuthEventListener
|
||||
DB::table('authlog')->insert(['user' => $user->username ?: '', 'address' => Request::ip(), 'result' => 'Logged In']);
|
||||
|
||||
Toastr::info('Welcome ' . ($user->realname ?: $user->username));
|
||||
|
||||
// Authenticated, set up legacy session stuff. TODO Remove once ajax and graphs are ported to Laravel.
|
||||
LegacyAuth::setUpLegacySession();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,9 +49,5 @@ class AuthEventListener
|
||||
$user = $event->user ?: (object)['username' => 'Not found'];
|
||||
|
||||
DB::table('authlog')->insert(['user' => $user->username ?: '', 'address' => Request::ip(), 'result' => 'Logged Out']);
|
||||
|
||||
@session_start();
|
||||
unset($_SESSION['authenticated']);
|
||||
session_destroy();
|
||||
}
|
||||
}
|
||||
|
@@ -12,12 +12,10 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth', 'alerts');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -13,12 +13,10 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -10,12 +10,10 @@
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -15,12 +15,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,6 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
session_start();
|
||||
if (isset($_SESSION['stage']) && $_SESSION['stage'] == 2) {
|
||||
$init_modules = array('web', 'nodb');
|
||||
@@ -22,7 +20,7 @@ if (isset($_SESSION['stage']) && $_SESSION['stage'] == 2) {
|
||||
$init_modules = array('web', 'auth', 'alerts');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,9 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
@@ -43,7 +41,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die(json_encode($results));
|
||||
} elseif ($_REQUEST['type'] == 'device') {
|
||||
// Device search
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `devices` LEFT JOIN `locations` ON `locations`.`id` = `devices`.`location_id` WHERE `devices`.`hostname` LIKE ? OR `locations`.`location` LIKE ? OR `devices`.`sysName` LIKE ? OR `devices`.`purpose` LIKE ? OR `devices`.`notes` LIKE ? ORDER BY `devices`.hostname LIMIT " . $limit,
|
||||
["%$search%", "%$search%", "%$search%", "%$search%", "%$search%"]
|
||||
@@ -51,7 +49,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `devices` AS `D` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` LEFT JOIN `locations` ON `locations`.`id` = `D`.`location_id` WHERE `P`.`user_id` = ? AND (D.`hostname` LIKE ? OR D.`sysName` LIKE ? OR `locations`.`location` LIKE ?) ORDER BY hostname LIMIT " . $limit,
|
||||
[LegacyAuth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
[Auth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -74,10 +72,10 @@ if (isset($_REQUEST['search'])) {
|
||||
$highlight_colour = '#008000';
|
||||
}
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ?', [$result['device_id']]);
|
||||
} else {
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND D.device_id = ?', [LegacyAuth::id(), $result['device_id']]);
|
||||
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND D.device_id = ?', [Auth::id(), $result['device_id']]);
|
||||
}
|
||||
|
||||
$device[] = array(
|
||||
@@ -99,7 +97,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'ports') {
|
||||
// Search ports
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE ? OR `ifDescr` LIKE ? OR `ifName` LIKE ? ORDER BY ifDescr LIMIT ".$limit,
|
||||
["%$search%", "%$search%", "%$search%"]
|
||||
@@ -107,7 +105,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE ? OR `ifDescr` LIKE ? OR `ifName` LIKE ?) ORDER BY ifDescr LIMIT ".$limit,
|
||||
[LegacyAuth::id(), LegacyAuth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
[Auth::id(), Auth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -151,7 +149,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'bgp') {
|
||||
// Search bgp peers
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `bgpPeers`.*,`devices`.* FROM `bgpPeers` LEFT JOIN `devices` ON `bgpPeers`.`device_id` = `devices`.`device_id` WHERE `astext` LIKE ? OR `bgpPeerIdentifier` LIKE ? OR `bgpPeerRemoteAs` LIKE ? ORDER BY `astext` LIMIT " . $limit,
|
||||
["%$search%", "%$search%", "%$search%"]
|
||||
@@ -159,7 +157,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `bgpPeers`.*,`D`.* FROM `bgpPeers`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `bgpPeers`.`device_id`=`D`.`device_id` AND (`astext` LIKE ? OR `bgpPeerIdentifier` LIKE ? OR `bgpPeerRemoteAs` LIKE ?) ORDER BY `astext` LIMIT ".$limit,
|
||||
[LegacyAuth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
[Auth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -207,7 +205,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'applications') {
|
||||
// Device search
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `applications` INNER JOIN `devices` ON devices.device_id = applications.device_id WHERE `app_type` LIKE ? OR `hostname` LIKE ? ORDER BY hostname LIMIT ".$limit,
|
||||
["%$search%", "%$search%"]
|
||||
@@ -215,7 +213,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `applications` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `applications`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`app_type` LIKE ? OR `hostname` LIKE ?) ORDER BY hostname LIMIT ".$limit,
|
||||
[LegacyAuth::id(), "%$search%", "%$search%"]
|
||||
[Auth::id(), "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -254,7 +252,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'munin') {
|
||||
// Device search
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `munin_plugins` INNER JOIN `devices` ON devices.device_id = munin_plugins.device_id WHERE `mplug_type` LIKE ? OR `mplug_title` LIKE ? OR `hostname` LIKE ? ORDER BY hostname LIMIT ".$limit,
|
||||
["%$search%", "%$search%", "%$search%"]
|
||||
@@ -262,7 +260,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT * FROM `munin_plugins` INNER JOIN `devices` AS `D` ON `D`.`device_id` = `munin_plugins`.`device_id` INNER JOIN `devices_perms` AS `P` ON `P`.`device_id` = `D`.`device_id` WHERE `P`.`user_id` = ? AND (`mplug_type` LIKE ? OR `mplug_title` LIKE ? OR `hostname` LIKE ?) ORDER BY hostname LIMIT ".$limit,
|
||||
[LegacyAuth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
[Auth::id(), "%$search%", "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -301,7 +299,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'iftype') {
|
||||
// Device search
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `ports`.ifType FROM `ports` WHERE `ifType` LIKE ? GROUP BY ifType ORDER BY ifType LIMIT ".$limit,
|
||||
["%$search%"]
|
||||
@@ -309,7 +307,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `I`.ifType FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifType` LIKE ?) GROUP BY ifType ORDER BY ifType LIMIT ".$limit,
|
||||
[LegacyAuth::id(), LegacyAuth::id(), "%$search%"]
|
||||
[Auth::id(), Auth::id(), "%$search%"]
|
||||
);
|
||||
}
|
||||
if (count($results)) {
|
||||
@@ -327,7 +325,7 @@ if (isset($_REQUEST['search'])) {
|
||||
die($json);
|
||||
} elseif ($_REQUEST['type'] == 'bill') {
|
||||
// Device search
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` WHERE `bill_name` LIKE ? OR `bill_notes` LIKE ? LIMIT ".$limit,
|
||||
["%$search%", "%$search%"]
|
||||
@@ -335,7 +333,7 @@ if (isset($_REQUEST['search'])) {
|
||||
} else {
|
||||
$results = dbFetchRows(
|
||||
"SELECT `bills`.bill_id, `bills`.bill_name FROM `bills` INNER JOIN `bill_perms` ON `bills`.bill_id = `bill_perms`.bill_id WHERE `bill_perms`.user_id = ? AND (`bill_name` LIKE ? OR `bill_notes` LIKE ?) LIMIT ".$limit,
|
||||
[LegacyAuth::id(), "%$search%", "%$search%"]
|
||||
[Auth::id(), "%$search%", "%$search%"]
|
||||
);
|
||||
}
|
||||
$json = json_encode($results);
|
||||
|
@@ -12,12 +12,10 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -12,13 +12,12 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
$init_modules = ['web', 'auth'];
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
|
@@ -9,14 +9,12 @@
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$start = microtime(true);
|
||||
|
||||
$init_modules = array('web', 'graphs', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
$auth = LegacyAuth::check() || is_client_authorized($_SERVER['REMOTE_ADDR']);
|
||||
$auth = Auth::check() || is_client_authorized($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if (!$auth) {
|
||||
die('Unauthorized');
|
||||
|
@@ -11,7 +11,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
$links = 1;
|
||||
@@ -19,7 +18,7 @@ $links = 1;
|
||||
$init_modules = array('web', 'auth');
|
||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
die('Unauthorized');
|
||||
}
|
||||
|
||||
@@ -53,7 +52,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
graph [bgcolor=transparent];
|
||||
';
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
$map .= "\"Not authenticated\" [fontsize=20 fillcolor=\"lightblue\", URL=\"/\" shape=box3d]\n";
|
||||
} else {
|
||||
$locations = getlocations();
|
||||
@@ -223,7 +222,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) {
|
||||
}
|
||||
echo $img;
|
||||
} else {
|
||||
if (LegacyAuth::check()) {
|
||||
if (Auth::check()) {
|
||||
// FIXME level 10 only?
|
||||
echo '<center>
|
||||
<object width=1200 height=1000 data="' . Config::get('base_url') . '/network-map.php?format=svg" type="image/svg+xml"></object>
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['active_count'] = array('query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0');
|
||||
} else {
|
||||
$data['active_count'] = array(
|
||||
'query' => 'SELECT COUNT(`alerts`.`id`) FROM `alerts` LEFT JOIN `devices` ON `alerts`.`device_id`=`devices`.`device_id` LEFT JOIN `devices_perms` AS `DP` ON `devices`.`device_id` = `DP`.`device_id` RIGHT JOIN `alert_rules` ON `alerts`.`rule_id`=`alert_rules`.`id` WHERE 1 AND `alerts`.`state` NOT IN (0,2) AND `devices`.`disabled` = 0 AND `devices`.`ignore` = 0 AND `DP`.`user_id`=?',
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
}
|
||||
|
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['count'] = array('query' => 'SELECT COUNT(*) FROM devices');
|
||||
|
||||
$data['up'] = array('query' => "SELECT COUNT(*) FROM devices WHERE `status` = '1' AND `ignore` = '0' AND `disabled` = '0'",);
|
||||
@@ -15,26 +13,26 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
} else {
|
||||
$data['count'] = array(
|
||||
'query' => 'SELECT COUNT(*) FROM devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id`',
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['up'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND D.`status` = '1' AND D.`ignore` = '0' AND D.`disabled` = '0'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['down'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND D.`status` = '0' AND D.`ignore` = '0' AND D.`disabled` = '0'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['ignored'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND D.`ignore` = '1' AND D.`disabled` = '0'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['disabled'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND D.`disabled` = '1'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
}//end if
|
||||
|
@@ -22,16 +22,14 @@
|
||||
* @subpackage Notifications
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$data['count'] = array(
|
||||
'query' => 'select count(notifications.notifications_id) from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?)',
|
||||
'params' => array( LegacyAuth::id() )
|
||||
'params' => array( Auth::id() )
|
||||
);
|
||||
|
||||
$data['unread'] = array(
|
||||
'query' => 'select notifications.* from notifications where not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.user_id = ?) order by notifications.notifications_id desc',
|
||||
'params' => array( LegacyAuth::id() )
|
||||
'params' => array( Auth::id() )
|
||||
);
|
||||
|
||||
$data['sticky'] = array(
|
||||
@@ -44,5 +42,5 @@ $data['sticky_count'] = array(
|
||||
|
||||
$data['read'] = array(
|
||||
'query' => 'select notifications.* from notifications inner join notifications_attribs on notifications.notifications_id = notifications_attribs.notifications_id where notifications_attribs.user_id = ? && ( notifications_attribs.key = "read" && notifications_attribs.value = 1) && not exists( select 1 from notifications_attribs where notifications.notifications_id = notifications_attribs.notifications_id and notifications_attribs.key = "sticky" && notifications_attribs.value = "1") order by notifications_attribs.attrib_id desc',
|
||||
'params' => array( LegacyAuth::id() )
|
||||
'params' => array( Auth::id() )
|
||||
);
|
||||
|
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['count'] = array('query' => "SELECT COUNT(*) FROM ports WHERE `deleted` = '0'");
|
||||
|
||||
$data['up'] = array('query' => "SELECT COUNT(*) FROM ports AS I, devices AS D WHERE I.`deleted` = '0' AND D.`device_id` = I.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'up'",);
|
||||
@@ -17,31 +15,31 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
} else {
|
||||
$data['count'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id`",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['up'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'up'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['down'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifOperStatus` = 'down' AND I.`ifAdminStatus` = 'up'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['shutdown'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND I.`ifAdminStatus` = 'down'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['errored'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id` AND I.`ignore` = '0' AND D.`ignore` = '0' AND (I.`ifInErrors_delta` > '0' OR I.`ifOutErrors_delta` > '0')",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['ignored'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM ports AS I, devices AS D, devices_perms AS P WHERE I.`deleted` = '0' AND P.`user_id` = ? AND P.`device_id` = D.`device_id` AND I.`device_id` = D.`device_id` AND (I.`ignore` = '1' OR D.`ignore` = '1')",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
}//end if
|
||||
|
@@ -1,8 +1,6 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['count'] = array( 'query' => 'SELECT COUNT(*) FROM services');
|
||||
$data['up'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '0'");
|
||||
$data['down'] = array( 'query' => "SELECT COUNT(*) FROM services WHERE `service_ignore` = '0' AND `service_disabled` = '0' AND `service_status` = '2'");
|
||||
@@ -11,26 +9,26 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
} else {
|
||||
$data['count'] = array(
|
||||
'query' => 'SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id`',
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['up'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '0'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['down'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '0' AND S.`service_disabled` = '0' AND S.`service_status` = '2'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['ignored'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_ignore` = '1' AND S.`service_disabled` = '0'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
|
||||
$data['disabled'] = array(
|
||||
'query' => "SELECT COUNT(*) FROM services AS S, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND S.`device_id` = D.`device_id` AND S.`service_disabled` = '1'",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
}//end if
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$data['count'] = array('query' => "SELECT COUNT(`toner_id`) FROM toner");
|
||||
} else {
|
||||
$data['count'] = array(
|
||||
'query' => "SELECT COUNT(`toner_id`) FROM toner AS T, devices AS D, devices_perms AS P WHERE P.`user_id` = ? AND P.`device_id` = D.`device_id` AND T.`device_id` = D.`device_id`",
|
||||
'params' => array(LegacyAuth::id()),
|
||||
'params' => array(Auth::id()),
|
||||
);
|
||||
}
|
||||
|
@@ -16,11 +16,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\Git;
|
||||
use LibreNMS\Util\Html;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\Laravel;
|
||||
|
||||
@@ -1704,7 +1702,7 @@ function get_user_pref($name, $default = null, $user_id = null)
|
||||
}
|
||||
|
||||
if (is_null($user_id)) {
|
||||
$user_id = LegacyAuth::id();
|
||||
$user_id = Auth::id();
|
||||
}
|
||||
|
||||
$pref = dbFetchCell(
|
||||
@@ -1733,7 +1731,7 @@ function set_user_pref($name, $value, $user_id = null)
|
||||
{
|
||||
global $user_prefs;
|
||||
if (is_null($user_id)) {
|
||||
$user_id = LegacyAuth::id();
|
||||
$user_id = Auth::id();
|
||||
}
|
||||
|
||||
$pref = array(
|
||||
|
@@ -11,8 +11,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Events\QueryExecuted;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\HostExistsException;
|
||||
use LibreNMS\Exceptions\HostIpExistsException;
|
||||
@@ -24,9 +22,9 @@ use LibreNMS\Exceptions\SnmpVersionUnsupportedException;
|
||||
use LibreNMS\Util\IPv4;
|
||||
use LibreNMS\Util\IPv6;
|
||||
use LibreNMS\Util\MemcacheLock;
|
||||
use Symfony\Component\Process\Process;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use LibreNMS\Util\Time;
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
if (!function_exists('set_debug')) {
|
||||
/**
|
||||
@@ -886,7 +884,7 @@ function log_event($text, $device = null, $type = null, $severity = 2, $referenc
|
||||
'datetime' => \Carbon\Carbon::now(),
|
||||
'severity' => $severity,
|
||||
'message' => $text,
|
||||
'username' => isset(LegacyAuth::user()->username) ? LegacyAuth::user()->username : '',
|
||||
'username' => Auth::user()->username ?? '',
|
||||
], 'eventlog');
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
if (isset($settings['mode_select']) && $settings['mode_select'] !== '') {
|
||||
@@ -175,9 +174,9 @@ if (defined('SHOW_SETTINGS')) {
|
||||
|
||||
$sql = 'SELECT `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`status`, `D`.`uptime`, `D`.`os`, `D`.`icon`, `D`.`ignore`, `D`.`disabled` FROM `devices` AS `D`';
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
$sql .= ' , `devices_perms` AS P WHERE D.`device_id` = P.`device_id` AND P.`user_id` = ? AND ';
|
||||
$param = [LegacyAuth::id()];
|
||||
$param = [Auth::id()];
|
||||
} else {
|
||||
$sql .= ' WHERE ';
|
||||
$param = [];
|
||||
@@ -255,12 +254,12 @@ if (defined('SHOW_SETTINGS')) {
|
||||
}
|
||||
|
||||
if (($mode == 1 || $mode == 2) && (Config::get('show_services') != 0)) {
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D where `S`.`device_id` = `D`.`device_id` ORDER BY '.$serviceOrderBy.';';
|
||||
$service_par = array();
|
||||
} else {
|
||||
$service_query = 'select `S`.`service_type`, `S`.`service_id`, `S`.`service_desc`, `S`.`service_status`, `D`.`hostname`, `D`.`sysName`, `D`.`device_id`, `D`.`os`, `D`.`icon` from services S, devices D, devices_perms P where `S`.`device_id` = `D`.`device_id` AND D.device_id = P.device_id AND P.user_id = ? ORDER BY '.$serviceOrderBy.';';
|
||||
$service_par = array(LegacyAuth::id());
|
||||
$service_par = array(Auth::id());
|
||||
}
|
||||
$services = dbFetchRows($service_query, $service_par);
|
||||
if (count($services) > 0) {
|
||||
|
@@ -23,7 +23,6 @@
|
||||
* @author Neil Lathwood <gh+n@laf.io>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
header('Content-type: application/json');
|
||||
@@ -60,7 +59,7 @@ if (!is_numeric($alert_id)) {
|
||||
'until_clear' => $until_clear,
|
||||
]);
|
||||
|
||||
$username = LegacyAuth::user()->username;
|
||||
$username = Auth::user()->username;
|
||||
$data = [
|
||||
'state' => $state,
|
||||
'open' => $open,
|
||||
|
@@ -22,11 +22,9 @@
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Unauthenticated',
|
||||
@@ -40,7 +38,7 @@ $message = 'unknown error';
|
||||
|
||||
$dashboard_name = display($_REQUEST['dashboard_name']);
|
||||
|
||||
if (!empty($dashboard_name) && ($dash_id = dbInsert(['dashboard_name' => $dashboard_name, 'user_id' => LegacyAuth::id()], 'dashboards'))) {
|
||||
if (!empty($dashboard_name) && ($dash_id = dbInsert(['dashboard_name' => $dashboard_name, 'user_id' => Auth::id()], 'dashboards'))) {
|
||||
$status = 'ok';
|
||||
$message = 'Dashboard ' . $dashboard_name . ' created';
|
||||
} else {
|
||||
|
@@ -24,11 +24,10 @@
|
||||
*/
|
||||
|
||||
use LibreNMS\Alerting\QueryBuilderParser;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'ERROR: You need to be admin',
|
||||
|
@@ -22,11 +22,9 @@
|
||||
* @subpackage Alerts
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$status = 'error';
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-Type: application/json');
|
||||
$response = array('status' => $status, 'message' => 'You need to be admin');
|
||||
die(json_encode($response));
|
||||
|
@@ -28,11 +28,10 @@ use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Translation\FileLoader;
|
||||
use Illuminate\Translation\Translator;
|
||||
use Illuminate\Validation\Factory;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = array('status' => 1, 'message' => 'You need to be admin');
|
||||
} else {
|
||||
$device_id = $_POST['device_id'];
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -12,13 +12,11 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,13 +12,11 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -26,11 +26,9 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin',
|
||||
|
@@ -13,9 +13,8 @@
|
||||
*/
|
||||
|
||||
use LibreNMS\Alert\AlertDB;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -10,11 +10,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin.'
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = array('status' =>1, 'message' => 'ERROR: You need to be admin to delete poller entries');
|
||||
} else {
|
||||
$id = $vars['id'];
|
||||
|
@@ -22,11 +22,9 @@
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Unauthenticated',
|
||||
@@ -41,8 +39,8 @@ $message = 'unknown error';
|
||||
$dashboard_id = (int)$_REQUEST['dashboard_id'];
|
||||
|
||||
if ($dashboard_id) {
|
||||
dbDelete('users_widgets', 'user_id = ? && dashboard_id = ?', [LegacyAuth::id(), $dashboard_id]);
|
||||
if (dbDelete('dashboards', 'user_id = ? && dashboard_id = ?', [LegacyAuth::id(), $dashboard_id])) {
|
||||
dbDelete('users_widgets', 'user_id = ? && dashboard_id = ?', [Auth::id(), $dashboard_id]);
|
||||
if (dbDelete('dashboards', 'user_id = ? && dashboard_id = ?', [Auth::id(), $dashboard_id])) {
|
||||
$status = 'ok';
|
||||
$message = 'Dashboard deleted';
|
||||
} else {
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = ['status' => 1, 'message' => 'You need to be admin'];
|
||||
} else {
|
||||
if ($_POST['device_id']) {
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = array('status' =>1, 'message' => 'ERROR: You need to be admin to delete poller entries');
|
||||
} else {
|
||||
$id = $vars['id'];
|
||||
|
@@ -11,9 +11,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = array('status' =>1, 'message' => 'ERROR: You need to be admin to delete services');
|
||||
} else {
|
||||
if (!is_numeric($vars['service_id'])) {
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'ERROR: You need to be admin.'
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -22,8 +22,6 @@
|
||||
* @subpackage Dashboards
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
$status = 'error';
|
||||
@@ -34,7 +32,7 @@ $dashboard_name = display($_REQUEST['dashboard_name']);
|
||||
$access = $_REQUEST['access'];
|
||||
|
||||
if (isset($dashboard_id) && isset($dashboard_name) && isset($access)) {
|
||||
if (dbUpdate(['dashboard_name'=> $dashboard_name,'access'=> $access], 'dashboards', '(user_id = ? || access = 2) && dashboard_id = ?', [LegacyAuth::id(), $dashboard_id]) >= 0) {
|
||||
if (dbUpdate(['dashboard_name'=> $dashboard_name,'access'=> $access], 'dashboards', '(user_id = ? || access = 2) && dashboard_id = ?', [Auth::id(), $dashboard_id]) >= 0) {
|
||||
$status = 'ok';
|
||||
$message = 'Dashboard ' . $dashboard_name . ' updated';
|
||||
} else {
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = array('status' => 1, 'message' => 'You need to be admin');
|
||||
} else {
|
||||
if (isset($_POST['viewtype'])) {
|
||||
|
@@ -16,15 +16,13 @@
|
||||
* @author Aldemir Akpinar <aldemir.akpinar@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$vm_query = "SELECT v.vmwVmDisplayName AS vmname, v.vmwVmState AS powerstat, v.device_id AS deviceid, d.hostname AS physicalsrv, d.sysname AS sysname, v.vmwVmGuestOS AS os, v.vmwVmMemSize AS memory, v.vmwVmCpus AS cpu FROM vminfo AS v LEFT JOIN devices AS d ON v.device_id = d.device_id";
|
||||
|
||||
$param = [];
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
$vm_query .= ' LEFT JOIN devices_perms AS DP ON d.device_id = DP.device_id';
|
||||
$uidwhere = ' AND DP.user_id = ?';
|
||||
$uid = [LegacyAuth::id()];
|
||||
$uid = [Auth::id()];
|
||||
} else {
|
||||
$uidwhere = '';
|
||||
$uid = [];
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -22,8 +22,6 @@
|
||||
* @subpackage Notifications
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
@@ -33,7 +31,7 @@ if (!isset($_REQUEST['action'])) {
|
||||
]));
|
||||
}
|
||||
|
||||
if (in_array($_REQUEST['action'], ['stick', 'unstick', 'create']) && !LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (in_array($_REQUEST['action'], ['stick', 'unstick', 'create']) && !Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'ERROR: Need to be GlobalAdmin or DemoUser',
|
||||
@@ -42,19 +40,19 @@ if (in_array($_REQUEST['action'], ['stick', 'unstick', 'create']) && !LegacyAuth
|
||||
|
||||
|
||||
if ($_REQUEST['action'] == 'read' && isset($_REQUEST['notification_id'])) {
|
||||
if (dbInsert(['notifications_id'=>$_REQUEST['notification_id'],'user_id'=>LegacyAuth::id(),'key'=>'read','value'=>1], 'notifications_attribs')) {
|
||||
if (dbInsert(['notifications_id'=>$_REQUEST['notification_id'],'user_id'=>Auth::id(),'key'=>'read','value'=>1], 'notifications_attribs')) {
|
||||
die(json_encode([
|
||||
'status' => 'ok',
|
||||
'message' => 'Set as Read',
|
||||
]));
|
||||
}
|
||||
} elseif ($_REQUEST['action'] == 'read-all-notif') {
|
||||
$unread = dbFetchColumn("SELECT `notifications_id` FROM `notifications` AS N WHERE NOT EXISTS ( SELECT 1 FROM `notifications_attribs` WHERE `notifications_id` = N.`notifications_id` AND `user_id`=? AND `key`='read' AND `value`=1)", [LegacyAuth::id()]);
|
||||
$unread = dbFetchColumn("SELECT `notifications_id` FROM `notifications` AS N WHERE NOT EXISTS ( SELECT 1 FROM `notifications_attribs` WHERE `notifications_id` = N.`notifications_id` AND `user_id`=? AND `key`='read' AND `value`=1)", [Auth::id()]);
|
||||
foreach ($unread as $notification_id) {
|
||||
dbInsert(
|
||||
[
|
||||
'notifications_id' => $notification_id,
|
||||
'user_id' => LegacyAuth::id(),
|
||||
'user_id' => Auth::id(),
|
||||
'key' => 'read',
|
||||
'value' => 1
|
||||
],
|
||||
@@ -66,21 +64,21 @@ if ($_REQUEST['action'] == 'read' && isset($_REQUEST['notification_id'])) {
|
||||
'message' => 'All notifications set as read',
|
||||
]));
|
||||
} elseif ($_REQUEST['action'] == 'stick' && isset($_REQUEST['notification_id'])) {
|
||||
if (dbInsert(['notifications_id'=>$_REQUEST['notification_id'],'user_id'=>LegacyAuth::id(),'key'=>'sticky','value'=>1], 'notifications_attribs')) {
|
||||
if (dbInsert(['notifications_id'=>$_REQUEST['notification_id'],'user_id'=>Auth::id(),'key'=>'sticky','value'=>1], 'notifications_attribs')) {
|
||||
die(json_encode([
|
||||
'status' => 'ok',
|
||||
'message' => 'Set as Sticky',
|
||||
]));
|
||||
}
|
||||
} elseif ($_REQUEST['action'] == 'unstick' && isset($_REQUEST['notification_id'])) {
|
||||
if (dbDelete('notifications_attribs', "notifications_id = ? && user_id = ? AND `key`='sticky'", [$_REQUEST['notification_id'],LegacyAuth::id()])) {
|
||||
if (dbDelete('notifications_attribs', "notifications_id = ? && user_id = ? AND `key`='sticky'", [$_REQUEST['notification_id'],Auth::id()])) {
|
||||
die(json_encode([
|
||||
'status' => 'ok',
|
||||
'message' => 'Removed Sticky',
|
||||
]));
|
||||
}
|
||||
} elseif ($_REQUEST['action'] == 'create' && (!empty($_REQUEST['title']) && !empty($_REQUEST['body']))) {
|
||||
if (dbInsert(['title'=>$_REQUEST['title'],'body'=>$_REQUEST['body'],'checksum'=>hash('sha512', LegacyAuth::id().'.LOCAL.'.$_REQUEST['title']),'source'=>LegacyAuth::id()], 'notifications')) {
|
||||
if (dbInsert(['title'=>$_REQUEST['title'],'body'=>$_REQUEST['body'],'checksum'=>hash('sha512', Auth::id().'.LOCAL.'.$_REQUEST['title']),'source'=>Auth::id()], 'notifications')) {
|
||||
die(json_encode([
|
||||
'status' => 'ok',
|
||||
'message' => 'Created',
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -13,9 +13,8 @@
|
||||
*/
|
||||
|
||||
use LibreNMS\Alerting\QueryBuilderParser;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -12,12 +12,9 @@
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$device_hostname = clean($_POST['device_hostname']);
|
||||
if (LegacyAuth::user()->hasGlobalAdmin() && isset($device_hostname)) {
|
||||
if (oxidized_node_update($device_hostname, "LibreNMS GUI refresh", LegacyAuth::user()->username)) {
|
||||
if (Auth::user()->hasGlobalAdmin() && isset($device_hostname)) {
|
||||
if (oxidized_node_update($device_hostname, "LibreNMS GUI refresh", Auth::user()->username)) {
|
||||
$status = 'ok';
|
||||
$message = 'Queued refresh in oxidized for device ' . $device_hostname;
|
||||
} else {
|
||||
|
@@ -10,9 +10,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = 'error';
|
||||
$message = 'ERROR: You need to be admin to reload Oxidized node list';
|
||||
} else {
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$status = ['status' => 1, 'message' => 'You need to be admin'];
|
||||
} else {
|
||||
$parent_ids = (array)$_POST['parent_ids'];
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -13,11 +13,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -13,11 +13,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -13,11 +13,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -10,11 +10,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -10,11 +10,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -24,11 +24,10 @@
|
||||
*/
|
||||
|
||||
use LibreNMS\Alerting\QueryBuilderParser;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'ERROR: You need to be admin',
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -13,10 +13,9 @@
|
||||
*/
|
||||
|
||||
use LibreNMS\Alert\AlertUtil;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
@@ -33,7 +31,7 @@ if (!is_numeric($_POST['user_id']) || !isset($_POST['token'])) {
|
||||
$create = dbInsert(array('user_id' => $_POST['user_id'], 'token_hash' => $_POST['token'], 'description' => $_POST['description']), 'api_tokens');
|
||||
if ($create > '0') {
|
||||
echo 'API token has been created';
|
||||
$_SESSION['api_token'] = true;
|
||||
Session::put('api_token', true);
|
||||
exit;
|
||||
} else {
|
||||
echo 'ERROR: An error occurred creating the API token';
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -23,11 +23,9 @@
|
||||
* @author Vivia Nguyen-Tran <vivia@ualberta.ca>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -12,11 +12,9 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -12,9 +12,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
header('Content-type: text/plain');
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::check()) {
|
||||
if (!Auth::check()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Unauthenticated',
|
||||
@@ -22,7 +20,7 @@ $widget_id = $vars['widget_id'];
|
||||
$dasboard_id = $vars['dashboard_id'];
|
||||
|
||||
if ($sub_type == 'remove' && is_numeric($widget_id)) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(LegacyAuth::id(),$dasboard_id)) == 1) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(Auth::id(),$dasboard_id)) == 1) {
|
||||
if ($widget_id == 0 || dbDelete('users_widgets', '`user_widget_id`=? AND `dashboard_id`=?', array($widget_id,$dasboard_id))) {
|
||||
$status = 'ok';
|
||||
$message = 'Widget ' . $widget_id . ' removed';
|
||||
@@ -32,7 +30,7 @@ if ($sub_type == 'remove' && is_numeric($widget_id)) {
|
||||
$message = 'ERROR: You don\'t have write access.';
|
||||
}
|
||||
} elseif ($sub_type == 'remove-all') {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(LegacyAuth::id(),$dasboard_id)) == 1) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(Auth::id(),$dasboard_id)) == 1) {
|
||||
if (dbDelete('users_widgets', '`dashboard_id`=?', array($dasboard_id))) {
|
||||
$status = 'ok';
|
||||
$message = 'All widgets removed';
|
||||
@@ -42,11 +40,11 @@ if ($sub_type == 'remove' && is_numeric($widget_id)) {
|
||||
$message = 'ERROR: You don\'t have write access.';
|
||||
}
|
||||
} elseif ($sub_type == 'add' && is_numeric($widget_id)) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(LegacyAuth::id(),$dasboard_id)) == 1) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(Auth::id(),$dasboard_id)) == 1) {
|
||||
$widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id));
|
||||
if (is_array($widget)) {
|
||||
list($x,$y) = explode(',', $widget['base_dimensions']);
|
||||
$item_id = dbInsert(array('user_id'=>LegacyAuth::id(),'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y,'settings'=>'','dashboard_id'=>$dasboard_id), 'users_widgets');
|
||||
$item_id = dbInsert(array('user_id'=>Auth::id(),'widget_id'=>$widget_id, 'col'=>1,'row'=>1,'refresh'=>60,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y,'settings'=>'','dashboard_id'=>$dasboard_id), 'users_widgets');
|
||||
if (is_numeric($item_id)) {
|
||||
$extra = array('user_widget_id'=>$item_id,'widget_id'=>$item_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'refresh'=>60,'size_x'=>$x,'size_y'=>$y);
|
||||
$status = 'ok';
|
||||
@@ -58,7 +56,7 @@ if ($sub_type == 'remove' && is_numeric($widget_id)) {
|
||||
$message = 'ERROR: You don\'t have write access.';
|
||||
}
|
||||
} else {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(LegacyAuth::id(),$dasboard_id)) == 1) {
|
||||
if (dbFetchCell('select 1 from dashboards where (user_id = ? || access = 2) && dashboard_id = ?', array(Auth::id(),$dasboard_id)) == 1) {
|
||||
$status = 'ok';
|
||||
$message = 'Widgets updated';
|
||||
foreach ($data as $line) {
|
||||
|
@@ -10,8 +10,6 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
$status = 'error';
|
||||
@@ -20,7 +18,7 @@ $message = 'unknown error';
|
||||
$device_id = mres($_POST['device_id']);
|
||||
$notes = $_POST['notes'];
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$message = 'Only admin accounts can update notes';
|
||||
} elseif (isset($notes) && (dbUpdate(array('notes' => $notes), 'devices', 'device_id = ?', array($device_id)))) {
|
||||
$status = 'ok';
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'message' => 'Need to be admin',
|
||||
|
@@ -13,13 +13,11 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: text/plain');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -13,13 +13,11 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -13,13 +13,11 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
// FUA
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die(json_encode([
|
||||
'status' => 'error',
|
||||
'message' => 'You need to be admin'
|
||||
|
@@ -13,12 +13,10 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$minutes = 15;
|
||||
$seconds = ($minutes * 60);
|
||||
$top = \LibreNMS\Config::get('front_page_settings.top.devices');
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$query = "
|
||||
SELECT *, sum(p.ifInOctets_rate + p.ifOutOctets_rate) as total
|
||||
FROM ports as p, devices as d
|
||||
@@ -43,7 +41,7 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
ORDER BY total desc
|
||||
LIMIT $top
|
||||
";
|
||||
$param[] = array(LegacyAuth::id());
|
||||
$param[] = array(Auth::id());
|
||||
}//end if
|
||||
|
||||
echo "<strong>Top $top devices (last $minutes minutes)</strong>\n";
|
||||
|
@@ -13,12 +13,10 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$minutes = 15;
|
||||
$seconds = ($minutes * 60);
|
||||
$top = \LibreNMS\Config::get('front_page_settings.top.ports');
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$query = "
|
||||
SELECT *, p.ifInOctets_rate + p.ifOutOctets_rate as total
|
||||
FROM ports as p, devices as d
|
||||
@@ -43,8 +41,8 @@ if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
LIMIT $top
|
||||
";
|
||||
$param[] = array(
|
||||
LegacyAuth::id(),
|
||||
LegacyAuth::id(),
|
||||
Auth::id(),
|
||||
Auth::id(),
|
||||
);
|
||||
}//end if
|
||||
|
||||
|
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
// FIXME - wtfbbq
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead() || $auth) {
|
||||
if (Auth::user()->hasGlobalRead() || $auth) {
|
||||
$id = mres($vars['id']);
|
||||
$title = generate_device_link($device);
|
||||
$auth = true;
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
$auth = 1;
|
||||
}
|
||||
|
@@ -23,16 +23,14 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
$query = '';
|
||||
$where = [];
|
||||
$params = [];
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
$query .= ' LEFT JOIN `devices_perms` USING (`device_id`)';
|
||||
$where = '`devices_perms`.`user_id`=?';
|
||||
$params[] = LegacyAuth::id();
|
||||
$params[] = Auth::id();
|
||||
}
|
||||
|
||||
if (!empty($_REQUEST['search'])) {
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Vivia Nguyen-Tran <vivia@ualberta>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Vivia Nguyen-Tran <vivia@ualberta>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (!Auth::user()->hasGlobalRead()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@@ -23,9 +23,7 @@
|
||||
* @author Neil Lathwood <neil@lathwood.co.uk>
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,7 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
if (!LegacyAuth::user()->hasGlobalAdmin()) {
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
die('ERROR: You need to be admin');
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user