mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-20 12:24:29 +02:00
lib: Add ExternalBackend::getRemoteUser()
If the user is authenticated via the web server, this method should be used to retrieve the user because it supports both reading the user from the environment or from the $_SERVER variable as fallback. refs #11391
This commit is contained in:
parent
c803ec64c5
commit
2ac54d7c3e
@ -52,6 +52,25 @@ class ExternalBackend implements UserBackendInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote user from environment or $_SERVER, if any
|
||||
*
|
||||
* @param string $variable The name variable where to read the user from
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function getRemoteUser($variable = 'REMOTE_USER')
|
||||
{
|
||||
$username = getenv($variable);
|
||||
if ($username !== false) {
|
||||
return $username;
|
||||
}
|
||||
if (array_key_exists($variable, $_SERVER)) {
|
||||
return $_SERVER[$variable];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
Loading…
x
Reference in New Issue
Block a user