mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Device group based access (#10568)
* Device group based access * Use Permissions class to resolve permissions Also give port access based on device access * Convert more pages to use Permissions class * shorten config setting name use Eloquent relationships in several places alphabetize config_definitions.json * Change Models and Permissions * Clean up ajax_search LIMIT sql * Convert more pages to use Permissions class Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
		@@ -28,12 +28,12 @@ $param = array();
 | 
			
		||||
$sql = 'FROM `ports`';
 | 
			
		||||
 | 
			
		||||
if (!Auth::user()->hasGlobalRead()) {
 | 
			
		||||
    $sql .= ' LEFT JOIN `devices_perms` AS `DP` ON `ports`.`device_id` = `DP`.`device_id`';
 | 
			
		||||
    $sql .= ' LEFT JOIN `ports_perms` AS `PP` ON `ports`.`port_id` = `PP`.`port_id`';
 | 
			
		||||
 | 
			
		||||
    $where .= ' AND (`DP`.`user_id`=? OR `PP`.`user_id`=?)';
 | 
			
		||||
    $param[] = Auth::id();
 | 
			
		||||
    $param[] = Auth::id();
 | 
			
		||||
    $port_ids = Permissions::portsForUser()->toArray() ?: [0];
 | 
			
		||||
    $device_ids = Permissions::devicesForUser()->toArray() ?: [0];
 | 
			
		||||
    $where .= " AND (`ports`.`port_id` IN " . dbGenPlaceholders(count($port_ids));
 | 
			
		||||
    $where .= " OR `D`.`device_id` IN " .dbGenPlaceholders(count($device_ids));
 | 
			
		||||
    $where .= ")";
 | 
			
		||||
    $param = array_merge($param, $port_ids, $device_ids);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$sql .= ' LEFT JOIN `devices` AS `D` ON `ports`.`device_id` = `D`.`device_id`';
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user