/** * Create the form-service * * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator * @return \Zend\Permissions\Acl\Acl */ public function createService(ServiceLocatorInterface $serviceLocator) { // Configure the locale $config = $serviceLocator->get('Configuration'); $srvConfig = isset($config['acl']) ? $config['acl'] : array(); $acl = new Acl(); if (!empty($srvConfig['roles'])) { foreach ((array) $srvConfig['roles'] as $role => $parents) { $acl->addRole((string) $role, $parents); } } if (!empty($srvConfig['resources'])) { foreach ((array) $srvConfig['resources'] as $resource => $parent) { $acl->addResource($resource, $parent); } } if (!empty($srvConfig['allow'])) { foreach ((array) $srvConfig['allow'] as $allow) { $acl->allow($allow['role'], $allow['resource'], $allow['privilege']); } } if (!empty($srvConfig['deny'])) { foreach ((array) $srvConfig['deny'] as $deny) { $acl->deny($deny['role'], $deny['resource'], $deny['privilege']); } } return $acl; }
public function testReturnsFalseIfIdentityFailsAcls() { $listener = $this->listener; $this->authorization->addResource('Foo\\Bar\\Controller::index'); $this->authorization->deny('guest', 'Foo\\Bar\\Controller::index', 'POST'); $this->mvcAuthEvent->setResource('Foo\\Bar\\Controller::index'); $this->mvcAuthEvent->getMvcEvent()->getRequest()->setMethod('POST'); $this->authentication->setIdentity(new GuestIdentity()); $this->assertFalse($listener($this->mvcAuthEvent)); }
/** * Установить acl * @param Acl $acl * @return Auth */ public function setAcl($acl) { if ($this->hasIdentity()) { $acl->allow('guest', 'autharea', 'signout'); $acl->deny('guest', 'autharea', array('signin', 'signup')); } $this->_acl = $acl; return $this; }