Allow full name to be retrieved by SSO ReverseProxy
Expand on #4585 by also getting the user's full name from the Reverse Proxy: If a ReverseProxy provides more than REMOTE_USER, such as email, it might as well also provide the user's full name.
This commit is contained in:
@@ -44,10 +44,11 @@ class ReverseProxyAuth extends Base implements PreAuthenticationProviderInterfac
|
||||
{
|
||||
$username = $this->request->getRemoteUser();
|
||||
$email = $this->request->getRemoteEmail();
|
||||
$fullname = $this->request->getRemoteName();
|
||||
|
||||
if (! empty($username)) {
|
||||
$userProfile = $this->userCacheDecorator->getByUsername($username);
|
||||
$this->userInfo = new ReverseProxyUserProvider($username, $email, $userProfile ?: array());
|
||||
$this->userInfo = new ReverseProxyUserProvider($username, $email, $fullname, $userProfile ?: array());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -291,6 +291,17 @@ class Request extends Base
|
||||
return $this->getServerVariable(REVERSE_PROXY_EMAIL_HEADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get remote user full name
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getRemoteName()
|
||||
{
|
||||
return $this->getServerVariable(REVERSE_PROXY_FULLNAME_HEADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns query string
|
||||
*
|
||||
|
||||
@@ -29,6 +29,14 @@ class ReverseProxyUserProvider implements UserProviderInterface
|
||||
*/
|
||||
protected $email = '';
|
||||
|
||||
/**
|
||||
* Full name
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $fullname= '';
|
||||
|
||||
/**
|
||||
* User profile if the user already exists
|
||||
*
|
||||
@@ -43,11 +51,13 @@ class ReverseProxyUserProvider implements UserProviderInterface
|
||||
* @access public
|
||||
* @param string $username
|
||||
* @param string $email
|
||||
* @param string $fullname
|
||||
*/
|
||||
public function __construct($username, $email, array $userProfile = array())
|
||||
public function __construct($username, $email, $fullname, array $userProfile = array())
|
||||
{
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
$this->fullname = $fullname;
|
||||
$this->userProfile = $userProfile;
|
||||
}
|
||||
|
||||
@@ -133,7 +143,7 @@ class ReverseProxyUserProvider implements UserProviderInterface
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return '';
|
||||
return $this->fullname;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -101,6 +101,7 @@ defined('LDAP_GROUP_SYNC') or define('LDAP_GROUP_SYNC', getenv('LDAP_GROUP_SYNC'
|
||||
defined('REVERSE_PROXY_AUTH') or define('REVERSE_PROXY_AUTH', strtolower(getenv('REVERSE_PROXY_AUTH')) === 'true');
|
||||
defined('REVERSE_PROXY_USER_HEADER') or define('REVERSE_PROXY_USER_HEADER', getenv('REVERSE_PROXY_USER_HEADER') ?: 'REMOTE_USER');
|
||||
defined('REVERSE_PROXY_EMAIL_HEADER') or define('REVERSE_PROXY_EMAIL_HEADER', getenv('REVERSE_PROXY_EMAIL_HEADER') ?: 'REMOTE_EMAIL');
|
||||
defined('REVERSE_PROXY_FULLNAME_HEADER') or define('REVERSE_PROXY_FULLNAME_HEADER', getenv('REVERSE_PROXY_FULLNAME_HEADER') ?: 'REMOTE_FULLNAME');
|
||||
defined('REVERSE_PROXY_DEFAULT_ADMIN') or define('REVERSE_PROXY_DEFAULT_ADMIN', getenv('REVERSE_PROXY_DEFAULT_ADMIN') ?: '');
|
||||
defined('REVERSE_PROXY_DEFAULT_DOMAIN') or define('REVERSE_PROXY_DEFAULT_DOMAIN', getenv('REVERSE_PROXY_DEFAULT_DOMAIN') ?: '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user