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,8 +31,15 @@ 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;
foreach (ExternalBackend::getRemoteUserEnvvars() as $envvar) {
if (ExternalBackend::getRemoteUser($envvar) !== null) {
$hasRemoteUser = true;
break;
}
}
if (! $hasRemoteUser) {
$this->info( $this->info(
$this->translate( $this->translate(
'You\'re currently not authenticated using any of the web server\'s authentication ' 'You\'re currently not authenticated using any of the web server\'s authentication '
@ -42,6 +49,7 @@ class AuthenticationPage extends Form
false false
); );
} }
}
$backendTypes = array(); $backendTypes = array();
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {