Skip to content
Snippets Groups Projects
Commit 3923fc0e authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

BjyAuthorize fournit maintennt lui-même les infos d'authentification à Navigation.

Améliorations diverses du service sans apport fonctionnel (reprise de coee provenant d'UnicaenAuth).
parent d5f887c3
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@ use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\View\Helper\Navigation;
/**
* BjyAuthorize Module
......@@ -31,6 +32,12 @@ class Module implements
$strategy = $serviceManager->get($config['unauthorized_strategy']);
$guards = $serviceManager->get('BjyAuthorize\Guards');
// transmission des ACL aux aides de vue de navigation
$authorizeService = $serviceManager->get('BjyAuthorize\Service\Authorize');
/* @var $authorizeService \BjyAuthorize\Service\Authorize */
Navigation::setDefaultAcl($authorizeService->getAcl());
Navigation::setDefaultRole($authorizeService->getIdentity());
foreach ($guards as $guard) {
/** @var AbstractListenerAggregate $guard */
$guard->attach($app->getEventManager());
......
......@@ -77,6 +77,13 @@ class Authorize
*/
protected $config;
/**
* Loading...
*
* @var boolean
*/
protected $loading;
/**
* @param array $config
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
......@@ -205,10 +212,6 @@ class Authorize
}
/**
* @deprecated this method will be removed in BjyAuthorize 1.4.x+,
* please retrieve the identity from the
* `BjyAuthorize\Provider\Identity\ProviderInterface` service
*
* @return string
*/
public function getIdentity()
......@@ -259,6 +262,7 @@ class Authorize
}
$this->loaded = null;
$this->loading = true;
/** @var $cache StorageInterface */
$cache = $this->serviceLocator->get('BjyAuthorize\Cache');
......@@ -280,6 +284,8 @@ class Authorize
$parentRoles = $this->getIdentityProvider()->getIdentityRoles();
$this->acl->addRole($this->getIdentity(), $parentRoles);
$this->loading = false;
}
/**
......@@ -308,6 +314,26 @@ class Authorize
}
}
/**
* Retourne la liste des rôles fournis par l'ensemble des providers
*/
public function getRoles()
{
$roles = [];
foreach ($this->roleProviders as $provider) {
$r = $provider->getRoles();
foreach ($r as $role) {
$roles[$role->getRoleId()] = $role;
}
}
return $roles;
}
/**
* @deprecated this method will be removed in BjyAuthorize 2.0.x
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment