Commit 5ec96155 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Amélioration : Authentification par base de données : Possibilité désormais de...

Amélioration : Authentification par base de données : Possibilité désormais de spécifier une connexion autre que la connexion principale 'orm_default'.
parent 39c91b1d
...@@ -58,9 +58,14 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se ...@@ -58,9 +58,14 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
$services = $application->getServiceManager(); $services = $application->getServiceManager();
// transmission des ACL aux aides de vue de navigation // transmission des ACL aux aides de vue de navigation
$authorizeService = $services->get('BjyAuthorize\Service\Authorize'); /* @var $authorizeService \BjyAuthorize\Service\Authorize */ try {
\Zend\View\Helper\Navigation::setDefaultAcl($authorizeService->getAcl()); $authorizeService = $services->get('BjyAuthorize\Service\Authorize'); /* @var $authorizeService \BjyAuthorize\Service\Authorize */
\Zend\View\Helper\Navigation::setDefaultRole($authorizeService->getIdentity()); \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 */ /* @var $options Options\ModuleOptions */
$options = $services->get('unicaen-auth_module_options'); $options = $services->get('unicaen-auth_module_options');
...@@ -153,6 +158,16 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se ...@@ -153,6 +158,16 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
{ {
return array( return array(
'factories' => 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 () { 'unicaen-auth_user_service' => function () {
return new Service\User(); return new Service\User();
}, },
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
$settings = array( $settings = array(
); );
$zfcuserSettings = array( $zfcuserSettings = array(
/** /**
* Enable registration * Enable registration
...@@ -57,6 +58,7 @@ $zfcuserSettings = array( ...@@ -57,6 +58,7 @@ $zfcuserSettings = array(
100 => 'UnicaenAuth\Authentication\Adapter\Cas', // ensuite (si échec d'authentification Db) 100 => 'UnicaenAuth\Authentication\Adapter\Cas', // ensuite (si échec d'authentification Db)
), ),
); );
$bjyauthorize = array( $bjyauthorize = array(
/* this module uses a meta-role that inherits from any roles that should /* 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 * be applied to the active user. the identity provider tells us which
...@@ -112,6 +114,14 @@ return array( ...@@ -112,6 +114,14 @@ return array(
'zfcuser' => $zfcuserSettings, 'zfcuser' => $zfcuserSettings,
'bjyauthorize' => $bjyauthorize, 'bjyauthorize' => $bjyauthorize,
'unicaen-auth' => $settings, 'unicaen-auth' => $settings,
'doctrine' => array(
'entitymanager' => array(
'orm_auth' => array(
'connection' => 'orm_auth',
'configuration' => 'orm_default'
)
),
),
'service_manager' => array( 'service_manager' => array(
'abstract_factories' => array( 'abstract_factories' => array(
'UnicaenAuth\Authentication\Adapter\AbstractFactory', 'UnicaenAuth\Authentication\Adapter\AbstractFactory',
...@@ -143,7 +153,7 @@ return array( ...@@ -143,7 +153,7 @@ return array(
), ),
'controllers' => array( 'controllers' => array(
'invokables' => array( 'invokables' => array(
'unicaen-auth' => 'UnicaenAuth\Controller\UtilisateurController',
), ),
), ),
'view_manager' => array( 'view_manager' => array(
...@@ -219,4 +229,4 @@ return array( ...@@ -219,4 +229,4 @@ return array(
), ),
), ),
), ),
); );
\ No newline at end of file
...@@ -12,9 +12,8 @@ $settings = array( ...@@ -12,9 +12,8 @@ $settings = array(
*/ */
'save_ldap_user_in_database' => false, 'save_ldap_user_in_database' => false,
/** /**
* Enable registration * Flag indiquant si l'utilisateur peut s'enregistrer auprès de l'application
* Allows users to register through the website. * (i.e. créer un compte dans la table des utilisateurs).
* Accepted values: boolean true or false
*/ */
'enable_registration' => false, 'enable_registration' => false,
); );
......
...@@ -6,6 +6,24 @@ ...@@ -6,6 +6,24 @@
* drop this config file in it and change the values as you wish. * drop this config file in it and change the values as you wish.
*/ */
$settings = array( $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 : * Paramètres de connexion au serveur CAS :
* - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide. * - pour désactiver l'authentification CAS, le tableau 'cas' doit être vide.
...@@ -36,4 +54,5 @@ $settings = array( ...@@ -36,4 +54,5 @@ $settings = array(
*/ */
return array( return array(
'unicaen-auth' => $settings, 'unicaen-auth' => $settings,
'doctrine' => isset($settings['doctrine']) ? $settings['doctrine'] : array(),
); );
\ 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