Files
librenms-librenms/LibreNMS/Authentication/HttpAuthAuthorizer.php
Tony Murray 2cd207028a Implement RBAC (only built in roles) (#15212)
* Install bouncer

* Seeder and level migration

* Display and edit roles

* remove unused deluser page

* Update Radius and SSO to assign roles

* update AlertUtil direct level check to use roles instead

* rewrite ircbot auth handling

* Remove legacy auth getUserlist and getUserlevel methods, add getRoles
Set roles in LegacyUserProvider

* Small cleanups

* centralize role sync code
show roles on user preferences page

* VueSelect component WIP and a little docs

* WIP

* SelectControllers id and text fields.

* LibrenmsSelect component extracted from SettingSelectDynamic

* Handle multiple selections

* allow type coercion

* full width settings

* final style adjustments

* Final compiled assets update

* Style fixes

* Fix SSO tests

* Lint cleanups

* small style fix

* don't use json yet

* Update baseline for usptream package issues

* Change schema, not 100% sure it is correct
not sure why xor doesn't work
2023-08-28 00:13:40 -05:00

52 lines
1.3 KiB
PHP

<?php
namespace LibreNMS\Authentication;
use LibreNMS\Config;
use LibreNMS\Exceptions\AuthenticationException;
class HttpAuthAuthorizer extends MysqlAuthorizer
{
protected static $HAS_AUTH_USERMANAGEMENT = true;
protected static $CAN_UPDATE_USER = true;
protected static $CAN_UPDATE_PASSWORDS = false;
protected static $AUTH_IS_EXTERNAL = true;
public function authenticate($credentials)
{
if (isset($credentials['username']) && $this->userExists($credentials['username'])) {
return true;
}
throw new AuthenticationException('No matching user found and http_auth_guest is not set');
}
public function userExists($username, $throw_exception = false)
{
if (parent::userExists($username)) {
return true;
}
if (Config::has('http_auth_guest') && parent::userExists(Config::get('http_auth_guest'))) {
return true;
}
return false;
}
public function getUserid($username)
{
$user_id = parent::getUserid($username);
if ($user_id) {
return $user_id;
}
if (Config::has('http_auth_guest')) {
return parent::getUserid(Config::get('http_auth_guest'));
}
return -1;
}
}