mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
ExternalBackend: make the variable a webserver assigns a username to configurable
refs #12164
This commit is contained in:
parent
29c221418b
commit
ce951295d3
@ -11,6 +11,13 @@ 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 +39,7 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,9 +87,10 @@ class ExternalBackend implements UserBackendInterface
|
|||||||
*/
|
*/
|
||||||
public function authenticate(User $user, $password = null)
|
public function authenticate(User $user, $password = null)
|
||||||
{
|
{
|
||||||
$username = static::getRemoteUser(null);
|
$usernameEnvvar = $this->config->username_envvar;
|
||||||
|
$username = static::getRemoteUser($usernameEnvvar);
|
||||||
if ($username !== null) {
|
if ($username !== null) {
|
||||||
$user->setExternalUserInformation($username, null);
|
$user->setExternalUserInformation($username, $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