Rewrite of the authentication and authorization system

This commit is contained in:
Frederic Guillot
2015-12-05 20:31:27 -05:00
parent 346b8312e5
commit e9fedf3e5c
255 changed files with 14114 additions and 9820 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Kanboard\Group;
use Kanboard\Core\Base;
use Kanboard\Core\Group\GroupBackendProviderInterface;
/**
* Database Backend Group Provider
*
* @package group
* @author Frederic Guillot
*/
class DatabaseBackendGroupProvider extends Base implements GroupBackendProviderInterface
{
/**
* Find a group from a search query
*
* @access public
* @param string $input
* @return []DatabaseGroupProvider
*/
public function find($input)
{
$result = array();
$groups = $this->group->search($input);
foreach ($groups as $group) {
$result[] = new DatabaseGroupProvider($group);
}
return $result;
}
}

View File

@@ -0,0 +1,66 @@
<?php
namespace Kanboard\Group;
use Kanboard\Core\Group\GroupProviderInterface;
/**
* Database Group Provider
*
* @package group
* @author Frederic Guillot
*/
class DatabaseGroupProvider implements GroupProviderInterface
{
/**
* Group properties
*
* @access private
* @var array
*/
private $group = array();
/**
* Constructor
*
* @access public
* @param array $group
*/
public function __construct(array $group)
{
$this->group = $group;
}
/**
* Get internal id
*
* @access public
* @return integer
*/
public function getInternalId()
{
return $this->group['id'];
}
/**
* Get external id
*
* @access public
* @return string
*/
public function getExternalId()
{
return '';
}
/**
* Get group name
*
* @access public
* @return string
*/
public function getName()
{
return $this->group['name'];
}
}

View File

@@ -0,0 +1,54 @@
<?php
namespace Kanboard\Group;
use LogicException;
use Kanboard\Core\Base;
use Kanboard\Core\Group\GroupBackendProviderInterface;
use Kanboard\Core\Ldap\Client as LdapClient;
use Kanboard\Core\Ldap\ClientException as LdapException;
use Kanboard\Core\Ldap\Group as LdapGroup;
/**
* LDAP Backend Group Provider
*
* @package group
* @author Frederic Guillot
*/
class LdapBackendGroupProvider extends Base implements GroupBackendProviderInterface
{
/**
* Find a group from a search query
*
* @access public
* @param string $input
* @return []LdapGroupProvider
*/
public function find($input)
{
try {
$ldap = LdapClient::connect();
return LdapGroup::getGroups($ldap, $this->getLdapGroupPattern($input));
} catch (LdapException $e) {
$this->logger->error($e->getMessage());
return array();
}
}
/**
* Get LDAP group pattern
*
* @access public
* @param string $input
* @return string
*/
public function getLdapGroupPattern($input)
{
if (empty(LDAP_GROUP_FILTER)) {
throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER');
}
return sprintf(LDAP_GROUP_FILTER, $input);
}
}

View File

@@ -0,0 +1,76 @@
<?php
namespace Kanboard\Group;
use Kanboard\Core\Group\GroupProviderInterface;
/**
* LDAP Group Provider
*
* @package group
* @author Frederic Guillot
*/
class LdapGroupProvider implements GroupProviderInterface
{
/**
* Group DN
*
* @access private
* @var string
*/
private $dn = '';
/**
* Group Name
*
* @access private
* @var string
*/
private $name = '';
/**
* Constructor
*
* @access public
* @param string $dn
* @param string $name
*/
public function __construct($dn, $name)
{
$this->dn = $dn;
$this->name = $name;
}
/**
* Get internal id
*
* @access public
* @return integer
*/
public function getInternalId()
{
return '';
}
/**
* Get external id
*
* @access public
* @return string
*/
public function getExternalId()
{
return $this->dn;
}
/**
* Get group name
*
* @access public
* @return string
*/
public function getName()
{
return $this->name;
}
}