diff --git a/Module.php b/Module.php index 6aa7b9a46b36febb122064389d1009721c82b0b8..ccf0c76d0768e29d24eb2b91538b11c590812d3a 100644 --- a/Module.php +++ b/Module.php @@ -58,9 +58,14 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se $services = $application->getServiceManager(); // transmission des ACL aux aides de vue de navigation - $authorizeService = $services->get('BjyAuthorize\Service\Authorize'); /* @var $authorizeService \BjyAuthorize\Service\Authorize */ - \Zend\View\Helper\Navigation::setDefaultAcl($authorizeService->getAcl()); - \Zend\View\Helper\Navigation::setDefaultRole($authorizeService->getIdentity()); + try { + $authorizeService = $services->get('BjyAuthorize\Service\Authorize'); /* @var $authorizeService \BjyAuthorize\Service\Authorize */ + \Zend\View\Helper\Navigation::setDefaultAcl($authorizeService->getAcl()); + \Zend\View\Helper\Navigation::setDefaultRole($authorizeService->getIdentity()); + } + catch (\Zend\ServiceManager\Exception\ServiceNotFoundException $snfe) { + // pas de module BjyAuthorize : pas d'ACL + } /* @var $options Options\ModuleOptions */ $options = $services->get('unicaen-auth_module_options'); @@ -153,6 +158,16 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se { return array( 'factories' => array( + 'zfcuser_user_mapper' => function ($sm) { + $config = $sm->get('configuration'); + $em = isset($config['doctrine']['connection']['orm_auth']) ? + 'doctrine.entitymanager.orm_auth' : + 'doctrine.entitymanager.orm_default'; + return new \ZfcUserDoctrineORM\Mapper\User( + $sm->get($em), + $sm->get('zfcuser_module_options') + ); + }, 'unicaen-auth_user_service' => function () { return new Service\User(); }, diff --git a/config/module.config.php b/config/module.config.php index 6f13081b89278d94a6f1d11114ffcdfa44609a14..024c842bab93e0083603fc6abeded5d1bbc02590 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -2,6 +2,7 @@ $settings = array( ); + $zfcuserSettings = array( /** * Enable registration @@ -57,6 +58,7 @@ $zfcuserSettings = array( 100 => 'UnicaenAuth\Authentication\Adapter\Cas', // ensuite (si échec d'authentification Db) ), ); + $bjyauthorize = array( /* this module uses a meta-role that inherits from any roles that should * be applied to the active user. the identity provider tells us which @@ -112,6 +114,14 @@ return array( 'zfcuser' => $zfcuserSettings, 'bjyauthorize' => $bjyauthorize, 'unicaen-auth' => $settings, + 'doctrine' => array( + 'entitymanager' => array( + 'orm_auth' => array( + 'connection' => 'orm_auth', + 'configuration' => 'orm_default' + ) + ), + ), 'service_manager' => array( 'abstract_factories' => array( 'UnicaenAuth\Authentication\Adapter\AbstractFactory', @@ -143,7 +153,7 @@ return array( ), 'controllers' => array( 'invokables' => array( - 'unicaen-auth' => 'UnicaenAuth\Controller\UtilisateurController', + ), ), 'view_manager' => array( @@ -219,4 +229,4 @@ return array( ), ), ), -); +); \ No newline at end of file diff --git a/config/unicaen-auth.global.php.dist b/config/unicaen-auth.global.php.dist index a9139cc014b581ca4349d68935a1403edb692f46..92bf71245ddf1de7d51fa77ca2066299828ded29 100644 --- a/config/unicaen-auth.global.php.dist +++ b/config/unicaen-auth.global.php.dist @@ -12,9 +12,8 @@ $settings = array( */ 'save_ldap_user_in_database' => false, /** - * Enable registration - * Allows users to register through the website. - * Accepted values: boolean true or false + * Flag indiquant si l'utilisateur peut s'enregistrer auprès de l'application + * (i.e. créer un compte dans la table des utilisateurs). */ 'enable_registration' => false, ); diff --git a/config/unicaen-auth.local.php.dist b/config/unicaen-auth.local.php.dist index e6b6b41177fea326e35cde13a6dfe2c779e16596..d0f1131b4ebad71f151e79c349b110d72fefc2e3 100644 --- a/config/unicaen-auth.local.php.dist +++ b/config/unicaen-auth.local.php.dist @@ -6,6 +6,24 @@ * drop this config file in it and change the values as you wish. */ $settings = array( + /** + * Connexion à la base de donnée d'authentification via Doctrine. + * Décommenter pour spécifier une connexion autre que la connexion principale 'orm_default'. + */ +// 'doctrine' => array( +// 'connection' => array( +// 'orm_auth' => array( +// 'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver', +// 'params' => array( +// 'host' => 'localhost', +// 'port' => '3306', +// 'user' => 'root', +// 'password' => 'root', +// 'dbname' => 'authdb', +// ) +// ), +// ), +// ), /** * Paramètres de connexion au serveur CAS : * - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide. @@ -36,4 +54,5 @@ $settings = array( */ return array( 'unicaen-auth' => $settings, + 'doctrine' => isset($settings['doctrine']) ? $settings['doctrine'] : array(), ); \ No newline at end of file