setup/AuthenticationPage: don't show the warning about external backend configuration if REDIRECT_REMOTE_USER is set

refs #12164
This commit is contained in:
Alexander A. Klimov 2016-10-18 15:19:13 +02:00
parent be4a31c8e1
commit d6ac6c8374
3 changed files with 28 additions and 11 deletions

View File

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

View File

@ -83,6 +83,15 @@ 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

@ -31,16 +31,24 @@ class AuthenticationPage extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
if (isset($formData['type']) && $formData['type'] === 'external' if (isset($formData['type']) && $formData['type'] === 'external') {
&& ExternalBackend::getRemoteUser(null) === null) { $hasRemoteUser = false;
$this->info( foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) {
$this->translate( if (ExternalBackend::getRemoteUser($envvar) !== null) {
'You\'re currently not authenticated using any of the web server\'s authentication ' $hasRemoteUser = true;
. 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' break;
. 'log into Icinga Web 2.' }
), }
false if (! $hasRemoteUser) {
); $this->info(
$this->translate(
'You\'re currently not authenticated using any of the web server\'s authentication '
. 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to '
. 'log into Icinga Web 2.'
),
false
);
}
} }
$backendTypes = array(); $backendTypes = array();