summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-06 14:48:59 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-06 14:48:59 -0500
commit70c65268fe017014b97dbc18e02588b8ed1d9a19 (patch)
treed843b97b1458e696f7e9e993295e5961cc06903d /app
parent6d4286ec664f1df8b0e97b759075afbf34d9620a (diff)
Update plugin doc
Diffstat (limited to 'app')
-rw-r--r--app/Auth/LdapAuth.php27
-rw-r--r--app/Auth/ReverseProxyAuth.php10
-rw-r--r--app/Core/Ldap/User.php24
-rw-r--r--app/Model/User.php2
-rw-r--r--app/Template/user/edit.php2
5 files changed, 33 insertions, 32 deletions
diff --git a/app/Auth/LdapAuth.php b/app/Auth/LdapAuth.php
index eb66e54d..85234ed3 100644
--- a/app/Auth/LdapAuth.php
+++ b/app/Auth/LdapAuth.php
@@ -23,7 +23,7 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
* @access private
* @var \Kanboard\User\LdapUserProvider
*/
- private $user = null;
+ private $userInfo = null;
/**
* Username
@@ -62,8 +62,8 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
{
try {
- $ldap = LdapClient::connect($this->getLdapUsername(), $this->getLdapPassword());
- $user = LdapUser::getUser($ldap, $this->getLdapUserPattern());
+ $client = LdapClient::connect($this->getLdapUsername(), $this->getLdapPassword());
+ $user = LdapUser::getUser($client, $this->username);
if ($user === null) {
$this->logger->info('User not found in LDAP server');
@@ -74,8 +74,8 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
throw new LogicException('Username not found in LDAP profile, check the parameter LDAP_USER_ATTRIBUTE_USERNAME');
}
- if ($ldap->authenticate($user->getDn(), $this->password)) {
- $this->user = $user;
+ if ($client->authenticate($user->getDn(), $this->password)) {
+ $this->userInfo = $user;
return true;
}
@@ -94,7 +94,7 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
*/
public function getUser()
{
- return $this->user;
+ return $this->userInfo;
}
/**
@@ -120,21 +120,6 @@ class LdapAuth extends Base implements PasswordAuthenticationProviderInterface
}
/**
- * Get LDAP user pattern
- *
- * @access public
- * @return string
- */
- public function getLdapUserPattern()
- {
- if (! LDAP_USER_FILTER) {
- throw new LogicException('LDAP user filter empty, check the parameter LDAP_USER_FILTER');
- }
-
- return sprintf(LDAP_USER_FILTER, $this->username);
- }
-
- /**
* Get LDAP username (proxy auth)
*
* @access public
diff --git a/app/Auth/ReverseProxyAuth.php b/app/Auth/ReverseProxyAuth.php
index 06573edb..b9730c5c 100644
--- a/app/Auth/ReverseProxyAuth.php
+++ b/app/Auth/ReverseProxyAuth.php
@@ -8,7 +8,7 @@ use Kanboard\Core\Security\SessionCheckProviderInterface;
use Kanboard\User\ReverseProxyUserProvider;
/**
- * ReverseProxy Authentication Provider
+ * Reverse-Proxy Authentication Provider
*
* @package auth
* @author Frederic Guillot
@@ -18,10 +18,10 @@ class ReverseProxyAuth extends Base implements PreAuthenticationProviderInterfac
/**
* User properties
*
- * @access private
+ * @access protected
* @var \Kanboard\User\ReverseProxyUserProvider
*/
- private $user = null;
+ protected $userInfo = null;
/**
* Get authentication provider name
@@ -45,7 +45,7 @@ class ReverseProxyAuth extends Base implements PreAuthenticationProviderInterfac
$username = $this->request->getRemoteUser();
if (! empty($username)) {
- $this->user = new ReverseProxyUserProvider($username);
+ $this->userInfo = new ReverseProxyUserProvider($username);
return true;
}
@@ -71,6 +71,6 @@ class ReverseProxyAuth extends Base implements PreAuthenticationProviderInterfac
*/
public function getUser()
{
- return $this->user;
+ return $this->userInfo;
}
}
diff --git a/app/Core/Ldap/User.php b/app/Core/Ldap/User.php
index ab8d7296..0c9df63f 100644
--- a/app/Core/Ldap/User.php
+++ b/app/Core/Ldap/User.php
@@ -34,18 +34,18 @@ class User
}
/**
- * Get user profile (helper)
+ * Get user profile
*
* @static
* @access public
* @param Client $client
- * @param string $query
+ * @param string $username
* @return array
*/
- public static function getUser(Client $client, $query)
+ public static function getUser(Client $client, $username)
{
$self = new self(new Query($client));
- return $self->find($query);
+ return $self->find($self->getLdapUserPattern($username));
}
/**
@@ -204,4 +204,20 @@ class User
return LDAP_USER_BASE_DN;
}
+
+ /**
+ * Get LDAP user pattern
+ *
+ * @access public
+ * @param string $username
+ * @return string
+ */
+ public function getLdapUserPattern($username)
+ {
+ if (! LDAP_USER_FILTER) {
+ throw new LogicException('LDAP user filter empty, check the parameter LDAP_USER_FILTER');
+ }
+
+ return sprintf(LDAP_USER_FILTER, $username);
+ }
}
diff --git a/app/Model/User.php b/app/Model/User.php
index 7142c258..50e9b310 100644
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -289,7 +289,7 @@ class User extends Base
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($values);
// If the user is connected refresh his session
- if (SessionManager::isOpen() && $this->userSession->getId() == $values['id']) {
+ if ($this->userSession->getId() == $values['id']) {
$this->userSession->initialize($this->getById($this->userSession->getId()));
}
diff --git a/app/Template/user/edit.php b/app/Template/user/edit.php
index 1a7fb430..f7f67fb7 100644
--- a/app/Template/user/edit.php
+++ b/app/Template/user/edit.php
@@ -8,7 +8,7 @@
<?= $this->form->hidden('id', $values) ?>
<?= $this->form->label(t('Username'), 'username') ?>
- <?= $this->form->text('username', $values, $errors, array('required', $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?>
+ <?= $this->form->text('username', $values, $errors, array('required', isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1 ? 'readonly' : '', 'maxlength="50"')) ?>
<?= $this->form->label(t('Name'), 'name') ?>
<?= $this->form->text('name', $values, $errors) ?>