Allow email to be retrieve by SSO ReverseProxy

If REMOTE_EMAIL header is set, use it as user email.
If REVERSE_PROXY_DEFAULT_DOMAIN is set but not REMOTE_EMAIL, use the current construct.
This commit is contained in:
mildis
2020-08-29 07:59:59 +02:00
committed by GitHub
parent 4dd586cdce
commit 33c3b32cda
6 changed files with 42 additions and 3 deletions

View File

@@ -21,6 +21,14 @@ class ReverseProxyUserProvider implements UserProviderInterface
*/
protected $username = '';
/**
* Email
*
* @access protected
* @var string
*/
protected $email = '';
/**
* User profile if the user already exists
*
@@ -34,10 +42,12 @@ class ReverseProxyUserProvider implements UserProviderInterface
*
* @access public
* @param string $username
* @param string $email
*/
public function __construct($username, array $userProfile = array())
public function __construct($username, $email, array $userProfile = array())
{
$this->username = $username;
$this->email = $email;
$this->userProfile = $userProfile;
}
@@ -134,7 +144,11 @@ class ReverseProxyUserProvider implements UserProviderInterface
*/
public function getEmail()
{
return REVERSE_PROXY_DEFAULT_DOMAIN !== '' ? $this->username.'@'.REVERSE_PROXY_DEFAULT_DOMAIN : '';
if (REVERSE_PROXY_DEFAULT_DOMAIN !== '' && $this->email === '') {
return $this->username.'@'.REVERSE_PROXY_DEFAULT_DOMAIN;
}
return $this->email;
}
/**