module.config.php 14.1 KB
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
2
<?php
$settings = array(
3
4
5
6
    /**
     * Fournisseurs d'identité.
     */
    'identity_providers' => array(
7
8
9
        300 => 'UnicaenAuth\Provider\Identity\Basic', // en 1er
        200 => 'UnicaenAuth\Provider\Identity\Db',    // en 2e
        100 => 'UnicaenAuth\Provider\Identity\Ldap',  // en 3e
10
    ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
11
);
12

Bertrand Gauthier's avatar
Bertrand Gauthier committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$zfcuserSettings = array(
    /**
     * Enable registration
     * Allows users to register through the website.
     * Accepted values: boolean true or false
     */
    'enable_registration' => true,
    /**
     * Modes for authentication identity match
     * Specify the allowable identity modes, in the order they should be
     * checked by the Authentication plugin.
     * Default value: array containing 'email'
     * Accepted values: array containing one or more of: email, username
     */
27
    'auth_identity_fields' => array('username', 'email'),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
    /**
     * Login Redirect Route
     * Upon successful login the user will be redirected to the entered route
     * Default value: 'zfcuser'
     * Accepted values: A valid route name within your application
     */
    'login_redirect_route' => 'home',
    /**
     * Logout Redirect Route
     * Upon logging out the user will be redirected to the enterd route
     * Default value: 'zfcuser/login'
     * Accepted values: A valid route name within your application
     */
    'logout_redirect_route' => 'home',
    /**
     * Enable Username
     * Enables username field on the registration form, and allows users to log
     * in using their username OR email address. Default is false.
     * Accepted values: boolean true or false
     */
48
    'enable_username' => false,
49
    /**     
Bertrand Gauthier's avatar
Bertrand Gauthier committed
50
51
52
53
54
55
     * 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,
Bertrand Gauthier's avatar
Bertrand Gauthier committed
56
57
58
59
60
61
62
63
    /**     
     * 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(
        300 => 'UnicaenAuth\Authentication\Adapter\Ldap', // notifié en 1er
64
        200 => 'UnicaenAuth\Authentication\Adapter\Db',   //         ensuite (si échec d'authentification Ldap)
Bertrand Gauthier's avatar
Bertrand Gauthier committed
65
        100 => 'UnicaenAuth\Authentication\Adapter\Cas',  //         ensuite (si échec d'authentification Db)
Bertrand Gauthier's avatar
Bertrand Gauthier committed
66
    ),
67
68
69
70
71
    
    // 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,
Bertrand Gauthier's avatar
Bertrand Gauthier committed
72
);
73
    
74
75
76
77
78
79
80
$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
     * roles the "identity role" should inherit from.
     *
     * for ZfcUser, this will be your default identity provider
     */
81
    'identity_provider' => 'UnicaenAuth\Provider\Identity\Chain',
82
83
84
85
86
87
88
    
    /* 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(
89
90
91
92
93
94
        /**
         * 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(
95
96
            'guest' => array('name' => "Non authentifié(e)", 'selectable' => false, 'children' => array(
                'user' => array('name' => "Authentifié(e)", 'selectable' => false)
97
98
99
100
101
102
            )),
        ),
        /**
         * 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!
103
         */
104
        'UnicaenAuth\Provider\Role\DbRole' => array(
105
106
            'object_manager'    => 'doctrine.entitymanager.orm_default',
            'role_entity_class' => 'UnicaenAuth\Entity\Db\Role',
107
        ),
108
109
110
111
112
113
        /**
         * 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(),
114
115
116
    ),

    // strategy service name for the strategy listener to be used when permission-related errors are detected
117
118
//    'unauthorized_strategy' => 'BjyAuthorize\View\RedirectionStrategy',
    'unauthorized_strategy' => 'UnicaenAuth\View\RedirectionStrategy',
119
    
120
121
122
123
124
125
126
127
    /* Currently, only controller and route guards exist
     */
    'guards' => array(
        /* 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(
128
129
130
            array('controller' => 'index', 'action' => 'index',   'roles' => array()),
            array('controller' => 'zfcuser',                      'roles' => array()),
            array('controller' => 'Application\Controller\Index', 'roles' => array()),
131

132
133
134
135
136
137
            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()),
138
            array('controller' => 'UnicaenApp\Controller\Application',  'action' => 'refresh-session',          'roles' => array()),
139
            array('controller' => 'UnicaenAuth\Controller\Utilisateur', 'action' => 'selectionner-profil',      'roles' => array()),
140
141
142
        ),
    ),
);
Bertrand Gauthier's avatar
Bertrand Gauthier committed
143
144
145

return array(
    'zfcuser' => $zfcuserSettings,
146
    'bjyauthorize' => $bjyauthorize,
Bertrand Gauthier's avatar
Bertrand Gauthier committed
147
    'unicaen-auth' => $settings,
148
    'doctrine' => array(
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
        'driver' => array(
            // overriding zfc-user-doctrine-orm's config
            'zfcuser_entity' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'paths' => array(
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db'
                )
            ),
            'orm_auth_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db'
                )
            ),
            'orm_default' => array(
                'class'   => 'Doctrine\ORM\Mapping\Driver\DriverChain',
                'drivers' => array(
                    'UnicaenAuth\Entity\Db' => 'zfcuser_entity',
                    'UnicaenAuth\Entity\Db' => 'orm_auth_driver'
                )
            ),
171
172
        ),
    ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
173
    'service_manager' => array(
174
175
176
177
        'aliases' => array(
            'Zend\Authentication\AuthenticationService' => 'zfcuser_auth_service',
        ),
        'invokables' => array(
178
179
180
            'unicaen-auth_user_service'               => 'UnicaenAuth\Service\User',
            'UnicaenAuth\Authentication\Storage\Db'   => 'UnicaenAuth\Authentication\Storage\Db',
            'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap',
181
            'UnicaenAuth\View\RedirectionStrategy'    => 'UnicaenAuth\View\RedirectionStrategy',
182
            'authUserContext'                         => 'UnicaenAuth\Service\UserContext'
183
        ),
184
185
186
        'abstract_factories' => array(
            'UnicaenAuth\Authentication\Adapter\AbstractFactory',
        ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
187
        'factories' => array(
188
189
            'unicaen-auth_module_options'              => 'UnicaenAuth\Options\ModuleOptionsFactory',
            'zfcuser_auth_service'                     => 'UnicaenAuth\Authentication\AuthenticationServiceFactory',
190
191
192
193
            'UnicaenAuth\Authentication\Storage\Chain' => 'UnicaenAuth\Authentication\Storage\ChainServiceFactory',
            'UnicaenAuth\Provider\Identity\Chain'      => 'UnicaenAuth\Provider\Identity\ChainServiceFactory',
            'UnicaenAuth\Provider\Identity\Ldap'       => 'UnicaenAuth\Provider\Identity\LdapServiceFactory',
            'UnicaenAuth\Provider\Identity\Db'         => 'UnicaenAuth\Provider\Identity\DbServiceFactory',
194
            'UnicaenAuth\Provider\Identity\Basic'         => 'UnicaenAuth\Provider\Identity\BasicServiceFactory',
195
            'UnicaenAuth\Provider\Role\Config'         => 'UnicaenAuth\Provider\Role\ConfigServiceFactory',
196
            'UnicaenAuth\Provider\Role\DbRole'         => 'UnicaenAuth\Provider\Role\DbRoleServiceFactory',
197
            'UnicaenAuth\Provider\Role\Username'       => 'UnicaenAuth\Provider\Role\UsernameServiceFactory',
Bertrand Gauthier's avatar
Bertrand Gauthier committed
198
        ),
199
200
201
        'initializers' => array(
            'UnicaenAuth\Service\UserAwareInitializer',
        ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
202
    ),
203
204
    'controllers' => array(
        'invokables' => array(
205
            'UnicaenAuth\Controller\Utilisateur' => 'UnicaenAuth\Controller\UtilisateurController',
206
207
        ),
    ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
208
    'view_manager' => array(
209
210
211
        'template_map' => array(
            'error/403' => __DIR__ . '/../view/error/403.phtml',
        ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
212
        'template_path_stack' => array(
213
            'unicaen-auth' => __DIR__ . '/../view',
Bertrand Gauthier's avatar
Bertrand Gauthier committed
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
        ),
    ),
    'translator' => array(
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'router' => array(
        'routes' => array(
            'zfcuser' => array(
                'type' => 'Literal',
                'priority' => 1000,
                'options' => array(
Bertrand Gauthier's avatar
Bertrand Gauthier committed
231
                    'route' => '/auth',
Bertrand Gauthier's avatar
Bertrand Gauthier committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
                    'defaults' => array(
                        'controller' => 'zfcuser',
                        'action'     => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'login' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/connexion',
                            'defaults' => array(
                                'controller' => 'zfcuser',
                                'action'     => 'login',
                            ),
                        ),
                    ),
                    'logout' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/deconnexion',
                            'defaults' => array(
                                'controller' => 'zfcuser',
                                'action'     => 'logout',
                            ),
                        ),
                    ),
259
260
261
262
263
264
265
266
267
268
                    'register' => array(
                        'type' => 'Literal',
                        'options' => array(
                            'route' => '/creation-compte',
                            'defaults' => array(
                                'controller' => 'zfcuser',
                                'action'     => 'register',
                            ),
                        ),
                    ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
269
270
                ),
            ),
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
            'utilisateur' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/utilisateur',
                    'defaults' => array(
                        '__NAMESPACE__' => 'UnicaenAuth\Controller',
                        'controller'    => 'Utilisateur',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    'default' => array(
                        'type'    => 'Segment',
                        'options' => array(
                            'route'    => '/:action[/:id]',
                            'constraints' => array(
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]*',
                            ),
                            'defaults' => array(
                                'action' => 'index',
                            ),
                        ),
                    ),
                ),
            ),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
298
299
300
301
302
303
304
305
306
307
        ),
    ),
    // All navigation-related configuration is collected in the 'navigation' key
    'navigation' => array(
        // The DefaultNavigationFactory we configured uses 'default' as the sitemap key
        'default' => array(
            // And finally, here is where we define our page hierarchy
            'home' => array(
                'pages' => array(
                    'login' => array(
308
                        'label'    => _("Connexion"),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
309
310
311
312
                        'route'    => 'zfcuser/login',
                        'visible'  => false,
                    ),
                    'register' => array(
313
                        'label'   => _("Enregistrement"),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
314
315
316
317
318
319
320
                        'route'   => 'zfcuser/register',
                        'visible' => false,
                    ),
                ),
            ),
        ),
    ),
321
);