Replace ExternalBackend::getRemoteUserEnvvars() with an attribute

refs #12164
This commit is contained in:
Alexander A. Klimov 2016-11-04 17:27:36 +01:00
parent f8501aa80d
commit d9330486e9
3 changed files with 9 additions and 12 deletions

View File

@ -57,7 +57,7 @@ class ExternalBackendForm extends Form
) )
); );
foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) { foreach (ExternalBackend::$remoteUserEnvvars as $envvar) {
if (ExternalBackend::getRemoteUser($envvar) !== null) { if (ExternalBackend::getRemoteUser($envvar) !== null) {
break; break;
} }

View File

@ -11,6 +11,13 @@ use Icinga\User;
*/ */
class ExternalBackend implements UserBackendInterface class ExternalBackend implements UserBackendInterface
{ {
/**
* Possible variables where to read the user from
*
* @var string[]
*/
public static $remoteUserEnvvars = array('REDIRECT_REMOTE_USER', 'REMOTE_USER');
/** /**
* The name of this backend * The name of this backend
* *
@ -83,16 +90,6 @@ class ExternalBackend implements UserBackendInterface
return null; return null;
} }
/**
* Get possible variables where to read the user from
*
* @return string[]
*/
public static function getRemoteUserEnvvars()
{
return array('REDIRECT_REMOTE_USER', 'REMOTE_USER');
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */

View File

@ -33,7 +33,7 @@ class AuthenticationPage extends Form
{ {
if (isset($formData['type']) && $formData['type'] === 'external') { if (isset($formData['type']) && $formData['type'] === 'external') {
$hasRemoteUser = false; $hasRemoteUser = false;
foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) { foreach (ExternalBackend::$remoteUserEnvvars as $envvar) {
if (ExternalBackend::getRemoteUser($envvar) !== null) { if (ExternalBackend::getRemoteUser($envvar) !== null) {
$hasRemoteUser = true; $hasRemoteUser = true;
break; break;