mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Move API routing to Laravel (#10457)
* Add more api helper functions to centralize code more * Enable cors * Initial Legacy route in Laravel * Force api v0 responses to json Add a couple more routes * more paths, pretty print the json response pass parameters to the api function * devices basic functions * Port generic graph function check permissions function accepts callback to avoid lots of if statements * move vlans * links * graphs * fdb * health * wireless * port graphs * ip functions split em up * port_stack * components * compoment add/edit/delete * get_device_groups * port stats * port graphs * get_devices_by_group * port_groups * api_get_graph * show_endpoints * get_bill * get_bill_graph * get_bill_graphdata * get_bill_history * get_bill_history_graph * remaining bill functions * list_alerts * ack/unmute alert * Some cleanups * Some cleanups * list_alert_rules * alert rule add/edit/delete * inventory * list_cbgp * vrf * list_ipsec * list_fdb * list_links (fix both usages) * list_locations * list_locations * list_vlans * list_ip_addresses * list_arp * list_ip_networks * cleanup * services * list_logs and fix authlog....... * cleanup * cleanup 2 * remove slim * don't load schema more than once * basic test * fix style * downgrade laravel-cors to a version that supports PHP 7.1
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
* @copyright (C) 2013 LibreNMS Group
|
||||
*/
|
||||
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
|
||||
/**
|
||||
@@ -288,11 +287,11 @@ function print_graph_popup($graph_array)
|
||||
|
||||
function bill_permitted($bill_id)
|
||||
{
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return \Permissions::canAccessBill($bill_id, LegacyAuth::id());
|
||||
return \Permissions::canAccessBill($bill_id, Auth::id());
|
||||
}
|
||||
|
||||
function port_permitted($port_id, $device_id = null)
|
||||
@@ -305,7 +304,7 @@ function port_permitted($port_id, $device_id = null)
|
||||
return true;
|
||||
}
|
||||
|
||||
return \Permissions::canAccessPort($port_id, LegacyAuth::id());
|
||||
return \Permissions::canAccessPort($port_id, Auth::id());
|
||||
}
|
||||
|
||||
function application_permitted($app_id, $device_id = null)
|
||||
@@ -323,10 +322,10 @@ function application_permitted($app_id, $device_id = null)
|
||||
|
||||
function device_permitted($device_id)
|
||||
{
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
return true;
|
||||
}
|
||||
return \Permissions::canAccessDevice($device_id, LegacyAuth::id());
|
||||
return \Permissions::canAccessDevice($device_id, Auth::id());
|
||||
}
|
||||
|
||||
function print_graph_tag($args)
|
||||
@@ -686,11 +685,11 @@ function devclass($device)
|
||||
|
||||
function getlocations()
|
||||
{
|
||||
if (LegacyAuth::user()->hasGlobalRead()) {
|
||||
if (Auth::user()->hasGlobalRead()) {
|
||||
return dbFetchRows('SELECT id, location FROM locations ORDER BY location');
|
||||
}
|
||||
|
||||
return dbFetchRows('SELECT id, L.location FROM devices AS D, locations AS L, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND D.location_id = L.id ORDER BY location', [LegacyAuth::id()]);
|
||||
return dbFetchRows('SELECT id, L.location FROM devices AS D, locations AS L, devices_perms AS P WHERE D.device_id = P.device_id AND P.user_id = ? AND D.location_id = L.id ORDER BY location', [Auth::id()]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user