Use getenv() instead of $_SERVER to get REMOTE_USER

refs #10488
This commit is contained in:
Alexander A. Klimov 2015-12-18 13:26:38 +01:00
parent 414a78d532
commit fc8873ec0a
3 changed files with 5 additions and 5 deletions

View File

@ -58,8 +58,8 @@ class ExternalBackend implements UserBackendInterface
*/ */
public function authenticate(User $user, $password = null) public function authenticate(User $user, $password = null)
{ {
if (isset($_SERVER['REMOTE_USER'])) { $username = getenv('REMOTE_USER');
$username = $_SERVER['REMOTE_USER']; if ($username !== false) {
$user->setExternalUserInformation($username, 'REMOTE_USER'); $user->setExternalUserInformation($username, 'REMOTE_USER');
if ($this->stripUsernameRegexp) { if ($this->stripUsernameRegexp) {

View File

@ -269,11 +269,11 @@ class AdminAccountPage extends Form
*/ */
protected function getUsername() protected function getUsername()
{ {
if (false === isset($_SERVER['REMOTE_USER'])) { $name = getenv('REMOTE_USER');
if ($name === false) {
return ''; return '';
} }
$name = $_SERVER['REMOTE_USER'];
if (isset($this->backendConfig['strip_username_regexp']) && $this->backendConfig['strip_username_regexp']) { if (isset($this->backendConfig['strip_username_regexp']) && $this->backendConfig['strip_username_regexp']) {
// No need to silence or log anything here because the pattern has // No need to silence or log anything here because the pattern has
// already been successfully compiled during backend configuration // already been successfully compiled during backend configuration

View File

@ -30,7 +30,7 @@ class AuthenticationPage extends Form
*/ */
public function createElements(array $formData) public function createElements(array $formData)
{ {
if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) { if (isset($formData['type']) && $formData['type'] === 'external' && getenv('REMOTE_USER') === false) {
$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 '