Commit 0027d462 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

AJout support des rôles (ACL) correspondant aux responsabilités structurelles (supannRoleEntite).

Simplification de la collecte des rôles de l'identité authentifiée.
parent b1d90cdf
......@@ -136,6 +136,8 @@ class People extends BasePeople implements UserInterface, ProviderInterface
*/
public function getRoles()
{
return $this->getMemberOf();
$roles = array_merge($this->getMemberOf(), $this->getSupannRolesEntite());
return $roles;
}
}
\ No newline at end of file
<?php
namespace UnicaenAuth\Provider\Identity;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Permissions\Acl\Role\RoleInterface;
use UnicaenAuth\Entity\Ldap\People;
use BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider;
......@@ -17,13 +14,8 @@ use BjyAuthorize\Provider\Identity\AuthenticationIdentityProvider;
*
* @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr>
*/
class Ldap extends AuthenticationIdentityProvider implements ChainableProvider, ServiceLocatorAwareInterface
class Ldap extends AuthenticationIdentityProvider implements ChainableProvider//, ServiceLocatorAwareInterface
{
/**
* @var ServiceLocatorInterface
*/
protected $serviceLocator;
/**
* {@inheritDoc}
*/
......@@ -52,38 +44,10 @@ class Ldap extends AuthenticationIdentityProvider implements ChainableProvider,
$roles = array();
}
if ($roles) {
$mapper = $this->getServiceLocator()->get('ldap_group_mapper'); /* @var $mapper \UnicaenApp\Mapper\Ldap\Group */
foreach ($roles as $key => $role) {
$group = $mapper->findOneByDn($role instanceof RoleInterface ? $role->getRoleId() : $role);
$roles[$key] = new \UnicaenAuth\Acl\NamedRole($role, null, $group ? $group->getDescription() : null);
}
}
if (!$roles) {
$roles = array($this->authenticatedRole);
}
return $roles;
}
/**
* Set service locator
*
* @param ServiceLocatorInterface $serviceLocator
*/
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
}
/**
* Get service locator
*
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator;
}
}
\ No newline at end of file
......@@ -49,6 +49,10 @@ class Config extends \BjyAuthorize\Provider\Role\Config
elseif (ldap_explode_dn($name, 1) !== false && ($group = $this->mapper->findOneByDn($name))) {
$roleName = $group->getDescription();
}
elseif (\UnicaenApp\Entity\Ldap\People::isSupannRoleEntite($name, $supann, $type, $code, $lib)) {
$code = \UnicaenApp\Entity\Ldap\Structure::extractCodeStructureHarpege($code);
$roleName = $lib . " ($supann, $code)";
}
else {
$roleName = null;
}
......@@ -59,7 +63,7 @@ class Config extends \BjyAuthorize\Provider\Role\Config
else {
$children = array();
}
$roles = array();
$role = new NamedRole($name, $parent, $roleName);
$roles[] = $role;
......@@ -72,7 +76,7 @@ class Config extends \BjyAuthorize\Provider\Role\Config
$roles = array_merge($roles, $this->loadRole($key, $value, $role));
}
}
return $roles;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment