mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
ExternalBackend: don't reference more than necessary from the config
refs #12164
This commit is contained in:
parent
ce951295d3
commit
ab01d2f915
@ -11,13 +11,6 @@ use Icinga\User;
|
|||||||
*/
|
*/
|
||||||
class ExternalBackend implements UserBackendInterface
|
class ExternalBackend implements UserBackendInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The configuration of this backend
|
|
||||||
*
|
|
||||||
* @var ConfigObject
|
|
||||||
*/
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this backend
|
* The name of this backend
|
||||||
*
|
*
|
||||||
@ -32,6 +25,13 @@ class ExternalBackend implements UserBackendInterface
|
|||||||
*/
|
*/
|
||||||
protected $stripUsernameRegexp;
|
protected $stripUsernameRegexp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name variable where to read the user from
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
*/
|
||||||
|
protected $usernameEnvvar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new authentication backend of type "external"
|
* Create new authentication backend of type "external"
|
||||||
*
|
*
|
||||||
@ -39,8 +39,8 @@ class ExternalBackend implements UserBackendInterface
|
|||||||
*/
|
*/
|
||||||
public function __construct(ConfigObject $config)
|
public function __construct(ConfigObject $config)
|
||||||
{
|
{
|
||||||
$this->config = $config;
|
|
||||||
$this->stripUsernameRegexp = $config->get('strip_username_regexp');
|
$this->stripUsernameRegexp = $config->get('strip_username_regexp');
|
||||||
|
$this->usernameEnvvar = $config->get('username_envvar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,10 +87,9 @@ class ExternalBackend implements UserBackendInterface
|
|||||||
*/
|
*/
|
||||||
public function authenticate(User $user, $password = null)
|
public function authenticate(User $user, $password = null)
|
||||||
{
|
{
|
||||||
$usernameEnvvar = $this->config->username_envvar;
|
$username = static::getRemoteUser($this->usernameEnvvar);
|
||||||
$username = static::getRemoteUser($usernameEnvvar);
|
|
||||||
if ($username !== null) {
|
if ($username !== null) {
|
||||||
$user->setExternalUserInformation($username, $usernameEnvvar);
|
$user->setExternalUserInformation($username, $this->usernameEnvvar);
|
||||||
|
|
||||||
if ($this->stripUsernameRegexp) {
|
if ($this->stripUsernameRegexp) {
|
||||||
$stripped = preg_replace($this->stripUsernameRegexp, '', $username);
|
$stripped = preg_replace($this->stripUsernameRegexp, '', $username);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user