Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
auth
Commits
29acec33
Commit
29acec33
authored
Oct 30, 2015
by
Laurent Lécluse
Browse files
Utilisation de la syntaxe courte pour les tableaux d'UnicaenAuth
parent
6efa4f5e
Changes
78
Hide whitespace changes
Inline
Side-by-side
Module.php
View file @
29acec33
...
...
@@ -9,13 +9,13 @@ use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
/**
* Point d'entrée du module d'authentification Unicaen.
*
*
* @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
*/
class
Module
implements
ConfigProviderInterface
,
ViewHelperProviderInterface
,
ServiceProviderInterface
{
/**
*
*
* @return array
* @see ConfigProviderInterface
*/
...
...
@@ -25,28 +25,28 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
}
/**
*
*
* @return array
* @see AutoloaderProviderInterface
*/
public
function
getAutoloaderConfig
()
{
return
array
(
'Zend\Loader\ClassMapAutoloader'
=>
array
(
return
[
'Zend\Loader\ClassMapAutoloader'
=>
[
__DIR__
.
'/autoload_classmap.php'
,
)
,
'Zend\Loader\StandardAutoloader'
=>
array
(
'namespaces'
=>
array
(
]
,
'Zend\Loader\StandardAutoloader'
=>
[
'namespaces'
=>
[
__NAMESPACE__
=>
__DIR__
.
'/src/'
.
__NAMESPACE__
,
)
,
)
,
)
;
]
,
]
,
]
;
}
/**
* This method is called once the MVC bootstrapping is complete,
* after the "loadModule.post" event, once $application->bootstrap() is called.
*
*
* @param EventInterface $e
* @see BootstrapListenerInterface
*/
...
...
@@ -55,7 +55,7 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
$application
=
$e
->
getApplication
();
/* @var $services \Zend\ServiceManager\ServiceManager */
$services
=
$application
->
getServiceManager
();
// transmission des ACL aux aides de vue de navigation
try
{
$authorizeService
=
$services
->
get
(
'BjyAuthorize\Service\Authorize'
);
/* @var $authorizeService \BjyAuthorize\Service\Authorize */
...
...
@@ -68,60 +68,60 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
/* @var $options Options\ModuleOptions */
$options
=
$services
->
get
(
'unicaen-auth_module_options'
);
// si l'auth CAS est demandée, modif de la route de connexion pour zapper le formulaire
if
(
$options
->
getCas
()
&&
php_sapi_name
()
!==
'cli'
)
{
/* @var $router \Zend\Mvc\Router\Http\TreeRouteStack */
$router
=
$services
->
get
(
'router'
);
$router
->
addRoutes
(
array
(
$router
->
addRoutes
(
[
// remplace les routes existantes (cf. config du module)
'zfcuser'
=>
array
(
'zfcuser'
=>
[
'type'
=>
'Literal'
,
'priority'
=>
1000
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/auth'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'index'
,
)
,
)
,
]
,
]
,
'may_terminate'
=>
true
,
'child_routes'
=>
array
(
'login'
=>
array
(
'child_routes'
=>
[
'login'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/connexion'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'authenticate'
,
// zappe l'action 'login'
)
,
)
,
)
,
'logout'
=>
array
(
]
,
]
,
]
,
'logout'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/deconnexion'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'logout'
,
)
,
)
,
)
,
)
,
)
)
);
]
,
]
,
]
,
]
,
]
]
);
}
}
/**
*
*
* @return array
* @see ViewHelperProviderInterface
*/
public
function
getViewHelperConfig
()
{
return
array
(
'factories'
=>
array
(
return
[
'factories'
=>
[
'userConnection'
=>
'UnicaenAuth\View\Helper\UserConnectionFactory'
,
'userCurrent'
=>
'UnicaenAuth\View\Helper\UserCurrentFactory'
,
'userStatus'
=>
'UnicaenAuth\View\Helper\UserStatusFactory'
,
...
...
@@ -129,22 +129,22 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
'userInfo'
=>
'UnicaenAuth\View\Helper\UserInfoFactory'
,
'userProfileSelect'
=>
'UnicaenAuth\View\Helper\UserProfileSelectFactory'
,
'userProfileSelectRadioItem'
=>
'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory'
,
)
,
'invokables'
=>
array
(
]
,
'invokables'
=>
[
'appConnection'
=>
'UnicaenAuth\View\Helper\AppConnection'
,
)
,
)
;
]
,
]
;
}
/**
*
*
* @return array
* @see ServiceProviderInterface
*/
public
function
getServiceConfig
()
{
return
array
(
'factories'
=>
array
(
return
[
'factories'
=>
[
// verrue pour forcer le label de l'identifiant qqsoit l'options 'auth_identity_fields'
'zfcuser_login_form'
=>
function
(
$sm
)
{
$options
=
$sm
->
get
(
'zfcuser_module_options'
);
...
...
@@ -153,7 +153,7 @@ class Module implements ConfigProviderInterface, ViewHelperProviderInterface, Se
$form
->
get
(
'identity'
)
->
setLabel
(
"Username"
);
return
$form
;
},
)
,
)
;
]
,
]
;
}
}
\ No newline at end of file
autoload_classmap.php
View file @
29acec33
<?php
// Generated by ZF2's ./bin/classmap_generator.php
return
array
(
return
[
'UnicaenAuth\Service\User'
=>
__DIR__
.
'/src/UnicaenAuth/Service/User.php'
,
'UnicaenAuth\Authentication\Storage\Ldap'
=>
__DIR__
.
'/src/UnicaenAuth/Authentication/Storage/Ldap.php'
,
'UnicaenAuth\Authentication\Storage\Db'
=>
__DIR__
.
'/src/UnicaenAuth/Authentication/Storage/Db.php'
,
...
...
@@ -21,4 +21,4 @@ return array(
'UnicaenAuth\View\Helper\UserConnection'
=>
__DIR__
.
'/src/UnicaenAuth/View/Helper/UserConnection.php'
,
'UnicaenAuth\View\Helper\UserAbstract'
=>
__DIR__
.
'/src/UnicaenAuth/View/Helper/UserAbstract.php'
,
'UnicaenAuth\Module'
=>
__DIR__
.
'/Module.php'
,
);
\ No newline at end of file
];
\ No newline at end of file
config/module.config.php
View file @
29acec33
<?php
$settings
=
array
(
$settings
=
[
/**
* Fournisseurs d'identité.
*/
'identity_providers'
=>
array
(
'identity_providers'
=>
[
300
=>
'UnicaenAuth\Provider\Identity\Basic'
,
// en 1er
200
=>
'UnicaenAuth\Provider\Identity\Db'
,
// en 2e
100
=>
'UnicaenAuth\Provider\Identity\Ldap'
,
// en 3e
)
,
)
;
]
,
]
;
$zfcuserSettings
=
array
(
$zfcuserSettings
=
[
/**
* Enable registration
* Allows users to register through the website.
...
...
@@ -24,7 +24,7 @@ $zfcuserSettings = array(
* Default value: array containing 'email'
* Accepted values: array containing one or more of: email, username
*/
'auth_identity_fields'
=>
array
(
'username'
,
'email'
)
,
'auth_identity_fields'
=>
[
'username'
,
'email'
]
,
/**
* Login Redirect Route
* Upon successful login the user will be redirected to the entered route
...
...
@@ -46,32 +46,32 @@ $zfcuserSettings = array(
* Accepted values: boolean true or false
*/
'enable_username'
=>
false
,
/**
/**
* Enable Display Name
* Enables a display name field on the registration form, which is persisted
* in the database. Default value is false.
* Accepted values: boolean true or false
*/
'enable_display_name'
=>
true
,
/**
/**
* Authentication Adapters
* Specify the adapters that will be used to try and authenticate the user
* Default value: array containing 'ZfcUser\Authentication\Adapter\Db' with priority 100
* Accepted values: array containing services that implement 'ZfcUser\Authentication\Adapter\ChainableAdapter'
*/
'auth_adapters'
=>
array
(
'auth_adapters'
=>
[
300
=>
'UnicaenAuth\Authentication\Adapter\Ldap'
,
// notifié en 1er
200
=>
'UnicaenAuth\Authentication\Adapter\Db'
,
// ensuite (si échec d'authentification Ldap)
100
=>
'UnicaenAuth\Authentication\Adapter\Cas'
,
// ensuite (si échec d'authentification Db)
)
,
]
,
// telling ZfcUser to use our own class
'user_entity_class'
=>
'UnicaenAuth\Entity\Db\User'
,
// telling ZfcUserDoctrineORM to skip the entities it defines
'enable_default_entities'
=>
false
,
)
;
$bjyauthorize
=
array
(
]
;
$bjyauthorize
=
[
/* 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
* roles the "identity role" should inherit from.
...
...
@@ -79,112 +79,112 @@ $bjyauthorize = array(
* for ZfcUser, this will be your default identity provider
*/
'identity_provider'
=>
'UnicaenAuth\Provider\Identity\Chain'
,
/* role providers simply provide a list of roles that should be inserted
* into the Zend\Acl instance. the module comes with two providers, one
* to specify roles in a config file and one to load roles using a
* Zend\Db adapter.
*/
'role_providers'
=>
array
(
'role_providers'
=>
[
/**
* 2 rôles doivent systématiquement exister dans les ACL :
* - le rôle par défaut 'guest', c'est le rôle de tout utilisateur non authentifié.
* - le rôle 'user', c'est le rôle de tout utilisateur authentifié.
*/
'UnicaenAuth\Provider\Role\Config'
=>
array
(
'guest'
=>
array
(
'name'
=>
"Non authentifié(e)"
,
'selectable'
=>
false
,
'children'
=>
array
(
'user'
=>
array
(
'name'
=>
"Authentifié(e)"
,
'selectable'
=>
false
)
))
,
)
,
'UnicaenAuth\Provider\Role\Config'
=>
[
'guest'
=>
[
'name'
=>
"Non authentifié(e)"
,
'selectable'
=>
false
,
'children'
=>
[
'user'
=>
[
'name'
=>
"Authentifié(e)"
,
'selectable'
=>
false
]
]]
,
]
,
/**
* Fournit les rôles issus de la base de données éventuelle de l'appli.
* NB: si le rôle par défaut 'guest' est fourni ici, il ne sera pas ajouté en double dans les ACL.
* NB: si la connexion à la base échoue, ce n'est pas bloquant!
*/
'UnicaenAuth\Provider\Role\DbRole'
=>
array
(
'UnicaenAuth\Provider\Role\DbRole'
=>
[
'object_manager'
=>
'doctrine.entitymanager.orm_default'
,
'role_entity_class'
=>
'UnicaenAuth\Entity\Db\Role'
,
)
,
]
,
/**
* Fournit le rôle correspondant à l'identifiant de connexion de l'utilisateur.
* Cela est utile lorsque l'on veut gérer les habilitations d'un utilisateur unique
* sur des ressources.
*/
'UnicaenAuth\Provider\Role\Username'
=>
array
()
,
)
,
'UnicaenAuth\Provider\Role\Username'
=>
[]
,
]
,
// strategy service name for the strategy listener to be used when permission-related errors are detected
// 'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy',
'unauthorized_strategy'
=>
'UnicaenAuth\View\RedirectionStrategy'
,
/* Currently, only controller and route guards exist
*/
'guards'
=>
array
(
'guards'
=>
[
/* If this guard is specified here (i.e. it is enabled), it will block
* access to all controllers and actions unless they are specified here.
* You may omit the 'action' index to allow access to the entire controller
*/
'BjyAuthorize\Guard\Controller'
=>
array
(
array
(
'controller'
=>
'index'
,
'action'
=>
'index'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'zfcuser'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'Application\Controller\Index'
,
'roles'
=>
array
())
,
'BjyAuthorize\Guard\Controller'
=>
[
[
'controller'
=>
'index'
,
'action'
=>
'index'
,
'roles'
=>
[]]
,
[
'controller'
=>
'zfcuser'
,
'roles'
=>
[]]
,
[
'controller'
=>
'Application\Controller\Index'
,
'roles'
=>
[]]
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'etab'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'apropos'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'contact'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'plan'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'mentions-legales'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'informatique-et-libertes'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'refresh-session'
,
'roles'
=>
array
())
,
array
(
'controller'
=>
'UnicaenAuth\Controller\Utilisateur'
,
'action'
=>
'selectionner-profil'
,
'roles'
=>
array
())
,
)
,
)
,
)
;
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'etab'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'apropos'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'contact'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'plan'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'mentions-legales'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'informatique-et-libertes'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenApp\Controller\Application'
,
'action'
=>
'refresh-session'
,
'roles'
=>
[]]
,
[
'controller'
=>
'UnicaenAuth\Controller\Utilisateur'
,
'action'
=>
'selectionner-profil'
,
'roles'
=>
[]]
,
]
,
]
,
]
;
return
array
(
return
[
'zfcuser'
=>
$zfcuserSettings
,
'bjyauthorize'
=>
$bjyauthorize
,
'unicaen-auth'
=>
$settings
,
'doctrine'
=>
array
(
'driver'
=>
array
(
'doctrine'
=>
[
'driver'
=>
[
// overriding zfc-user-doctrine-orm's config
'zfcuser_entity'
=>
array
(
'zfcuser_entity'
=>
[
'class'
=>
'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,
'paths'
=>
array
(
'paths'
=>
[
__DIR__
.
'/../src/UnicaenAuth/Entity/Db'
)
)
,
'orm_auth_driver'
=>
array
(
]
]
,
'orm_auth_driver'
=>
[
'class'
=>
'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,
'cache'
=>
'array'
,
'paths'
=>
array
(
'paths'
=>
[
__DIR__
.
'/../src/UnicaenAuth/Entity/Db'
)
)
,
'orm_default'
=>
array
(
]
]
,
'orm_default'
=>
[
'class'
=>
'Doctrine\ORM\Mapping\Driver\DriverChain'
,
'drivers'
=>
array
(
'drivers'
=>
[
'UnicaenAuth\Entity\Db'
=>
'zfcuser_entity'
,
'UnicaenAuth\Entity\Db'
=>
'orm_auth_driver'
)
)
,
)
,
)
,
'service_manager'
=>
array
(
'aliases'
=>
array
(
]
]
,
]
,
]
,
'service_manager'
=>
[
'aliases'
=>
[
'Zend\Authentication\AuthenticationService'
=>
'zfcuser_auth_service'
,
)
,
'invokables'
=>
array
(
]
,
'invokables'
=>
[
'unicaen-auth_user_service'
=>
'UnicaenAuth\Service\User'
,
'UnicaenAuth\Authentication\Storage\Db'
=>
'UnicaenAuth\Authentication\Storage\Db'
,
'UnicaenAuth\Authentication\Storage\Ldap'
=>
'UnicaenAuth\Authentication\Storage\Ldap'
,
'UnicaenAuth\View\RedirectionStrategy'
=>
'UnicaenAuth\View\RedirectionStrategy'
,
'authUserContext'
=>
'UnicaenAuth\Service\UserContext'
)
,
'abstract_factories'
=>
array
(
]
,
'abstract_factories'
=>
[
'UnicaenAuth\Authentication\Adapter\AbstractFactory'
,
)
,
'factories'
=>
array
(
]
,
'factories'
=>
[
'unicaen-auth_module_options'
=>
'UnicaenAuth\Options\ModuleOptionsFactory'
,
'zfcuser_auth_service'
=>
'UnicaenAuth\Authentication\AuthenticationServiceFactory'
,
'UnicaenAuth\Authentication\Storage\Chain'
=>
'UnicaenAuth\Authentication\Storage\ChainServiceFactory'
,
...
...
@@ -195,127 +195,127 @@ return array(
'UnicaenAuth\Provider\Role\Config'
=>
'UnicaenAuth\Provider\Role\ConfigServiceFactory'
,
'UnicaenAuth\Provider\Role\DbRole'
=>
'UnicaenAuth\Provider\Role\DbRoleServiceFactory'
,
'UnicaenAuth\Provider\Role\Username'
=>
'UnicaenAuth\Provider\Role\UsernameServiceFactory'
,
)
,
'initializers'
=>
array
(
]
,
'initializers'
=>
[
'UnicaenAuth\Service\UserAwareInitializer'
,
)
,
)
,
'controllers'
=>
array
(
'invokables'
=>
array
(
]
,
]
,
'controllers'
=>
[
'invokables'
=>
[
'UnicaenAuth\Controller\Utilisateur'
=>
'UnicaenAuth\Controller\UtilisateurController'
,
)
,
)
,
'view_manager'
=>
array
(
'template_map'
=>
array
(
]
,
]
,
'view_manager'
=>
[
'template_map'
=>
[
'error/403'
=>
__DIR__
.
'/../view/error/403.phtml'
,
)
,
'template_path_stack'
=>
array
(
]
,
'template_path_stack'
=>
[
'unicaen-auth'
=>
__DIR__
.
'/../view'
,
)
,
)
,
'translator'
=>
array
(
'translation_file_patterns'
=>
array
(
array
(
]
,
]
,
'translator'
=>
[
'translation_file_patterns'
=>
[
[
'type'
=>
'gettext'
,
'base_dir'
=>
__DIR__
.
'/../language'
,
'pattern'
=>
'%s.mo'
,
)
,
)
,
)
,
'router'
=>
array
(
'routes'
=>
array
(
'zfcuser'
=>
array
(
]
,
]
,
]
,
'router'
=>
[
'routes'
=>
[
'zfcuser'
=>
[
'type'
=>
'Literal'
,
'priority'
=>
1000
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/auth'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'index'
,
)
,
)
,
]
,
]
,
'may_terminate'
=>
true
,
'child_routes'
=>
array
(
'login'
=>
array
(
'child_routes'
=>
[
'login'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/connexion'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'login'
,
)
,
)
,
)
,
'logout'
=>
array
(
]
,
]
,
]
,
'logout'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/deconnexion'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'logout'
,
)
,
)
,
)
,
'register'
=>
array
(
]
,
]
,
]
,
'register'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/creation-compte'
,
'defaults'
=>
array
(
'defaults'
=>
[
'controller'
=>
'zfcuser'
,
'action'
=>
'register'
,
)
,
)
,
)
,
)
,
)
,
'utilisateur'
=>
array
(
]
,
]
,
]
,
]
,
]
,
'utilisateur'
=>
[
'type'
=>
'Literal'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/utilisateur'
,
'defaults'
=>
array
(
'defaults'
=>
[
'__NAMESPACE__'
=>
'UnicaenAuth\Controller'
,
'controller'
=>
'Utilisateur'
,
'action'
=>
'index'
,
)
,
)
,
]
,
]
,
'may_terminate'
=>
true
,
'child_routes'
=>
array
(
'default'
=>
array
(
'child_routes'
=>
[
'default'
=>
[
'type'
=>
'Segment'
,
'options'
=>
array
(
'options'
=>
[
'route'
=>
'/:action[/:id]'
,
'constraints'
=>
array
(
'constraints'
=>
[
'action'
=>
'[a-zA-Z][a-zA-Z0-9_-]*'
,
'id'
=>
'[0-9]*'
,
)
,
'defaults'
=>
array
(
]
,
'defaults'
=>
[
'action'
=>
'index'
,
)
,
)
,
)
,
)
,
)
,
)
,
)
,
]
,
]
,
]
,
]
,
]
,
]
,
]
,
// All navigation-related configuration is collected in the 'navigation' key
'navigation'
=>
array
(
'navigation'
=>
[
// The DefaultNavigationFactory we configured uses 'default' as the sitemap key
'default'
=>
array
(