Added more logging for LDAP client
This commit is contained in:
@@ -10,6 +10,7 @@ New features:
|
|||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
|
|
||||||
|
* Added more logging for LDAP client
|
||||||
* Improve schema migration process
|
* Improve schema migration process
|
||||||
* Improve notification configuration form
|
* Improve notification configuration form
|
||||||
* Handle state in OAuth2 client
|
* Handle state in OAuth2 client
|
||||||
|
|||||||
@@ -63,10 +63,12 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
$client = LdapClient::connect($this->getLdapUsername(), $this->getLdapPassword());
|
$client = LdapClient::connect($this->getLdapUsername(), $this->getLdapPassword());
|
||||||
|
$client->setLogger($this->logger);
|
||||||
|
|
||||||
$user = LdapUser::getUser($client, $this->username);
|
$user = LdapUser::getUser($client, $this->username);
|
||||||
|
|
||||||
if ($user === null) {
|
if ($user === null) {
|
||||||
$this->logger->info('User not found in LDAP server');
|
$this->logger->info('User ('.$this->username.') not found in LDAP server');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +76,8 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
|
|||||||
throw new LogicException('Username not found in LDAP profile, check the parameter LDAP_USER_ATTRIBUTE_USERNAME');
|
throw new LogicException('Username not found in LDAP profile, check the parameter LDAP_USER_ATTRIBUTE_USERNAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->logger->info('Authenticate user: '.$user->getDn());
|
||||||
|
|
||||||
if ($client->authenticate($user->getDn(), $this->password)) {
|
if ($client->authenticate($user->getDn(), $this->password)) {
|
||||||
$this->userInfo = $user;
|
$this->userInfo = $user;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Kanboard\Core\Ldap;
|
namespace Kanboard\Core\Ldap;
|
||||||
|
|
||||||
use LogicException;
|
use LogicException;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDAP Client
|
* LDAP Client
|
||||||
@@ -20,6 +21,14 @@ class Client
|
|||||||
*/
|
*/
|
||||||
protected $ldap;
|
protected $ldap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logger instance
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @var LoggerInterface
|
||||||
|
*/
|
||||||
|
private $logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Establish LDAP connection
|
* Establish LDAP connection
|
||||||
*
|
*
|
||||||
@@ -165,4 +174,28 @@ class Client
|
|||||||
{
|
{
|
||||||
return LDAP_PASSWORD;
|
return LDAP_PASSWORD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set logger
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param LoggerInterface $logger
|
||||||
|
* @return Client
|
||||||
|
*/
|
||||||
|
public function setLogger(LoggerInterface $logger)
|
||||||
|
{
|
||||||
|
$this->logger = $logger;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get logger
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return LoggerInterface
|
||||||
|
*/
|
||||||
|
public function getLogger()
|
||||||
|
{
|
||||||
|
return $this->logger;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ class Query
|
|||||||
*/
|
*/
|
||||||
public function execute($baseDn, $filter, array $attributes)
|
public function execute($baseDn, $filter, array $attributes)
|
||||||
{
|
{
|
||||||
|
if (DEBUG) {
|
||||||
|
$this->client->getLogger()->debug('BaseDN='.$baseDn);
|
||||||
|
$this->client->getLogger()->debug('Filter='.$filter);
|
||||||
|
$this->client->getLogger()->debug('Attributes='.implode(', ', $attributes));
|
||||||
|
}
|
||||||
|
|
||||||
$sr = ldap_search($this->client->getConnection(), $baseDn, $filter, $attributes);
|
$sr = ldap_search($this->client->getConnection(), $baseDn, $filter, $attributes);
|
||||||
if ($sr === false) {
|
if ($sr === false) {
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ class User
|
|||||||
*/
|
*/
|
||||||
public static function getUser(Client $client, $username)
|
public static function getUser(Client $client, $username)
|
||||||
{
|
{
|
||||||
$className = get_called_class();
|
$self = new static(new Query($client));
|
||||||
$self = new $className(new Query($client));
|
|
||||||
return $self->find($self->getLdapUserPattern($username));
|
return $self->find($self->getLdapUserPattern($username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user