mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Merge pull request #3178 from Ultra2D/api-ldap
API access when using LDAP authentication
This commit is contained in:
@@ -15,12 +15,20 @@
|
||||
require_once '../includes/functions.php';
|
||||
require_once '../includes/component.php';
|
||||
require_once '../includes/device-groups.inc.php';
|
||||
if (file_exists('../html/includes/authentication/'.$config['auth_mechanism'].'.inc.php')) {
|
||||
include '../html/includes/authentication/'.$config['auth_mechanism'].'.inc.php';
|
||||
}
|
||||
|
||||
function authToken(\Slim\Route $route) {
|
||||
$app = \Slim\Slim::getInstance();
|
||||
$token = $app->request->headers->get('X-Auth-Token');
|
||||
if (isset($token) && !empty($token)) {
|
||||
$username = dbFetchCell('SELECT `U`.`username` FROM `api_tokens` AS AT JOIN `users` AS U ON `AT`.`user_id`=`U`.`user_id` WHERE `AT`.`token_hash`=?', array($token));
|
||||
if (!function_exists('get_user')) {
|
||||
$username = dbFetchCell('SELECT `U`.`username` FROM `api_tokens` AS AT JOIN `users` AS U ON `AT`.`user_id`=`U`.`user_id` WHERE `AT`.`token_hash`=?', array($token));
|
||||
}
|
||||
else {
|
||||
$username = get_user(dbFetchCell('SELECT `AT`.`user_id` FROM `api_tokens` AS AT WHERE `AT`.`token_hash`=?', array($token)));
|
||||
}
|
||||
if (!empty($username)) {
|
||||
$authenticated = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user