|
<?php |
|
|
|
namespace Kanboard\User; |
|
|
|
use Kanboard\Core\User\UserProviderInterface; |
|
use Kanboard\Core\Security\Role; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReverseProxyUserProvider implements UserProviderInterface |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $username = ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $email = ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected $fullname= ''; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private $userProfile = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct($username, $email, $fullname, array $userProfile = array()) |
|
{ |
|
$this->username = $username; |
|
$this->email = $email; |
|
$this->fullname = $fullname; |
|
$this->userProfile = $userProfile; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function isUserCreationAllowed() |
|
{ |
|
return true; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getInternalId() |
|
{ |
|
return 0; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getExternalIdColumn() |
|
{ |
|
return 'username'; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getExternalId() |
|
{ |
|
return $this->username; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getRole() |
|
{ |
|
if (REVERSE_PROXY_DEFAULT_ADMIN === $this->username) { |
|
return Role::APP_ADMIN; |
|
} |
|
|
|
if (isset($this->userProfile['role'])) { |
|
return $this->userProfile['role']; |
|
} |
|
|
|
return Role::APP_USER; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getUsername() |
|
{ |
|
return $this->username; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getName() |
|
{ |
|
return $this->fullname; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getEmail() |
|
{ |
|
if (REVERSE_PROXY_DEFAULT_DOMAIN !== '' && $this->email === '') { |
|
return $this->username.'@'.REVERSE_PROXY_DEFAULT_DOMAIN; |
|
} |
|
|
|
return $this->email; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getExternalGroupIds() |
|
{ |
|
return array(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getExtraAttributes() |
|
{ |
|
return array( |
|
'is_ldap_user' => 1, |
|
'disable_login_form' => 1, |
|
); |
|
} |
|
} |
|
|