module.config.php 22.4 KB
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
<?php
2

3
4
5
use UnicaenAuth\Authentication\Storage\DbFactory;
use UnicaenAuth\Authentication\Storage\LdapFactory;
use UnicaenAuth\Authentication\Storage\ShibFactory;
6
use UnicaenAuth\Controller\AuthControllerFactory;
7
8
9
10
11
use UnicaenAuth\Controller\DroitsControllerFactory;
use UnicaenAuth\Controller\UtilisateurControllerFactory;
use UnicaenAuth\Form\Droits\RoleFormFactory;
use UnicaenAuth\Guard\PrivilegeControllerFactory;
use UnicaenAuth\Guard\PrivilegeRouteFactory;
12
13
use UnicaenAuth\Service\ShibService;
use UnicaenAuth\Service\ShibServiceFactory;
14
use UnicaenAuth\Service\UserContextFactory;
15
use UnicaenAuth\Service\UserFactory;
16
use UnicaenAuth\Service\UserMapperFactory;
17
use UnicaenAuth\View\Helper\LdapConnectViewHelperFactory;
18
use UnicaenAuth\View\Helper\LocalConnectViewHelperFactory;
19
use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory;
20
use UnicaenAuth\View\Helper\UserUsurpationHelperFactory;
21

22
$settings = [
23

24
25
26
27
28
29
30
31
32
33
    /**
     * Configuration de l'authentification locale.
     */
    'local' => [
        /**
         * Possibilité ou non de s'authentifier à l'aide d'un compte local.
         */
        'enabled' => true,
    ],

34
35
36
37
38
39
40
41
42
43
    /**
     * Configuration de l'authentification LDAP.
     */
    'ldap' => [
        /**
         * Possibilité ou non de s'authentifier via l'annuaire LDAP.
         */
        'enabled' => true,
    ],

44
45
46
    /**
     * Fournisseurs d'identité.
     */
47
    'identity_providers'  => [
48
49
        300 => 'UnicaenAuth\Provider\Identity\Basic', // en 1er
        200 => 'UnicaenAuth\Provider\Identity\Db',    // en 2e
50
        100 => 'UnicaenAuth\Provider\Identity\Ldap',  // en 3e @deprecated
51
    ],
52
53
54
55
56

    /**
     * Attribut LDAP utilisé pour le username des utilisateurs
     */
    'ldap_username' => 'supannaliaslogin',
57
58
];

59
60
return [
    'zfcuser'         => [
61
        /**
62
63
64
         * Enable registration
         * Allows users to register through the website.
         * Accepted values: boolean true or false
65
         */
66
        'enable_registration'     => true,
67
        /**
68
69
70
71
72
         * 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
73
         */
74
75
76
77
78
79
80
81
        'auth_identity_fields'    => ['username', 'email'],
        /**
         * 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',
82
        /**
83
84
85
86
         * 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
87
         */
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
        '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
         */
        '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'           => [
            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,
119
    ],
120
    'bjyauthorize'    => [
121

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
        /* 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'    => [
            /**
             * 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'   => [
                'guest' => ['name' => "Non authentifié(e)", 'selectable' => false, 'children' => [
                    'user' => ['name' => "Authentifié(e)", 'selectable' => false],
                ]],
            ],
        ],

        // 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
145
         */
146
147
148
149
150
151
152
153
154
        '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'         => [
                ['controller' => 'index', 'action' => 'index', 'roles' => []],
                ['controller' => 'zfcuser', 'roles' => []],
                ['controller' => 'Application\Controller\Index', 'roles' => []],
155

156
157
158
159
160
161
162
163
                ['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' => []],
164
165

                ['controller' => 'UnicaenAuth\Controller\Auth', 'action' => 'shibboleth', 'roles' => []],
166
167
                ['controller' => 'UnicaenAuth\Controller\Auth', 'action' => 'requestPasswordReset', 'roles' => []],
                ['controller' => 'UnicaenAuth\Controller\Auth', 'action' => 'changePassword', 'roles' => []],
168
            ],
169
170
        ],
    ],
171
172
    'unicaen-auth'    => $settings,
    'doctrine'        => [
173
        'driver' => [
174
            // overriding zfc-user-doctrine-orm's config
175
            'zfcuser_entity'  => [
176
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
177
                'paths' => [
178
179
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db',
                ],
180
181
            ],
            'orm_auth_driver' => [
182
183
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
184
                'paths' => [
185
186
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db',
                ],
187
            ],
188
            'orm_default'     => [
189
                'class'   => 'Doctrine\ORM\Mapping\Driver\DriverChain',
190
                'drivers' => [
191
                    'UnicaenAuth\Entity\Db' => 'zfcuser_entity',
192
193
                    'UnicaenAuth\Entity\Db' => 'orm_auth_driver',
                ],
194
195
196
            ],
        ],
    ],
197
198
    'view_manager'    => [
        'template_map'        => [
199
            'error/403' => __DIR__ . '/../view/error/403.phtml',
200
201
        ],
        'template_path_stack' => [
202
            'unicaen-auth' => __DIR__ . '/../view',
203
204
        ],
    ],
205
    'translator'      => [
206
207
        'translation_file_patterns' => [
            [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
208
209
210
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
211
212
213
            ],
        ],
    ],
214
    'router'          => [
215
        'routes' => [
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
            'auth'     => [
                'type'          => 'Literal',
                'options'       => [
                    'route'    => '/auth',
                    'defaults' => [
                        'controller' => 'UnicaenAuth\Controller\Auth',
                    ],
                ],
                'may_terminate' => false,
                'child_routes'  => [
                    'shibboleth' => [
                        'type' => 'Literal',
                        'options' => [
                            'route'    => '/shibboleth',
                            'defaults' => [
                                'action'     => 'shibboleth',
                            ],
                        ],
                    ],
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
                    'requestPasswordReset' => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/request-password-reset',
                            'defaults' => [
                                'action'     => 'requestPasswordReset',
                            ],
                        ],
                    ],
                    'changePassword' => [
                        'type'    => 'Segment',
                        'options' => [
                            'route'    => '/change-password/:token',
                            'defaults' => [
                                'action'     => 'changePassword',
                            ],
                        ],
                    ],
253
254
                ],
            ],
255
256
257
258
259
            'zfcuser'     => [
                'type'          => 'Literal',
                'priority'      => 1000,
                'options'       => [
                    'route'    => '/auth',
260
                    'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
261
262
                        'controller' => 'zfcuser',
                        'action'     => 'index',
263
264
                    ],
                ],
Bertrand Gauthier's avatar
Bertrand Gauthier committed
265
                'may_terminate' => true,
266
267
268
                'child_routes'  => [
                    'login'    => [
                        'type'    => 'Literal',
269
                        'options' => [
270
                            'route'    => '/connexion',
271
                            'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
272
273
                                'controller' => 'zfcuser',
                                'action'     => 'login',
274
275
276
                            ],
                        ],
                    ],
277
278
                    'logout'   => [
                        'type'    => 'Literal',
279
                        'options' => [
280
                            'route'    => '/deconnexion',
281
                            'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
282
283
                                'controller' => 'zfcuser',
                                'action'     => 'logout',
284
285
286
287
                            ],
                        ],
                    ],
                    'register' => [
288
                        'type'    => 'Literal',
289
                        'options' => [
290
                            'route'    => '/creation-compte',
291
                            'defaults' => [
292
293
                                'controller' => 'zfcuser',
                                'action'     => 'register',
294
295
296
297
298
299
                            ],
                        ],
                    ],
                ],
            ],
            'utilisateur' => [
300
301
                'type'          => 'Literal',
                'options'       => [
302
                    'route'    => '/utilisateur',
303
                    'defaults' => [
304
305
306
                        '__NAMESPACE__' => 'UnicaenAuth\Controller',
                        'controller'    => 'Utilisateur',
                        'action'        => 'index',
307
308
                    ],
                ],
309
                'may_terminate' => true,
310
                'child_routes'  => [
311
                    'default' => [
312
                        'type'    => 'Segment',
313
                        'options' => [
314
                            'route'       => '/:action[/:id]',
315
                            'constraints' => [
316
317
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]*',
318
                            ],
319
                            'defaults'    => [
320
                                'action' => 'index',
321
322
323
324
325
                            ],
                        ],
                    ],
                ],
            ],
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
            'droits'      => [
                'type'          => 'Literal',
                'options'       => [
                    'route'    => '/droits',
                    'defaults' => [
                        '__NAMESPACE__' => 'UnicaenAuth\Controller',
                        'controller'    => 'Droits',
                        'action'        => 'index',
                    ],
                ],
                'may_terminate' => true,
                'child_routes'  => [
                    'roles'      => [
                        'type'          => 'Segment',
                        'may_terminate' => true,
                        'options'       => [
                            'route'    => '/roles',
                            'defaults' => [
                                'action' => 'roles',
                            ],
                        ],
                        'child_routes'  => [
                            'edition'     => [
                                'type'          => 'Segment',
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/edition[/:role]',
                                    'constraints' => [
                                        'role' => '[0-9]*',
                                    ],
                                    'defaults'    => [
                                        'action' => 'role-edition',
                                    ],
                                ],
                            ],
                            'suppression' => [
                                'type'          => 'Segment',
                                'may_terminate' => true,
                                'options'       => [
                                    'route'       => '/suppression/:role',
                                    'constraints' => [
                                        'role' => '[0-9]*',
                                    ],
                                    'defaults'    => [
                                        'action' => 'role-suppression',
                                    ],
                                ],
                            ],
                        ],
                    ],
                    'privileges' => [
                        'type'          => 'Literal',
                        'may_terminate' => true,
                        'options'       => [
                            'route'    => '/privileges',
                            'defaults' => [
                                'action' => 'privileges',
                            ],
                        ],
                        'child_routes'  => [
                            'modifier' => [
                                'type'          => 'Segment',
                                'may_terminate' => true,
                                'options'       => [
                                    'route'    => '/modifier',
                                    'defaults' => [
                                        'action' => 'privileges-modifier',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
400
401
        ],
    ],
Bertrand Gauthier's avatar
Bertrand Gauthier committed
402
    // All navigation-related configuration is collected in the 'navigation' key
403
    'navigation'      => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
404
        // The DefaultNavigationFactory we configured uses 'default' as the sitemap key
405
        'default' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
406
            // And finally, here is where we define our page hierarchy
407
408
            'home' => [
                'pages' => [
409
410
411
412
                    'login'    => [
                        'label'   => _("Connexion"),
                        'route'   => 'zfcuser/login',
                        'visible' => false,
413
414
                    ],
                    'register' => [
415
                        'label'   => _("Enregistrement"),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
416
417
                        'route'   => 'zfcuser/register',
                        'visible' => false,
418
419
420
421
422
                    ],
                ],
            ],
        ],
    ],
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
    'service_manager' => [
        'aliases'            => [
            'Zend\Authentication\AuthenticationService' => 'zfcuser_auth_service',
            'UnicaenAuth\Privilege\PrivilegeProvider'   => 'UnicaenAuth\Service\Privilege',

            'unicaen-auth_user_service'               => 'UnicaenAuth\Service\User', // pour la compatibilité
            'authUserContext'                         => 'UnicaenAuth\Service\UserContext', // pour la compatibilité
        ],
        'invokables'         => [
            'UnicaenAuth\View\RedirectionStrategy'    => 'UnicaenAuth\View\RedirectionStrategy',
            'UnicaenAuth\Service\CategoriePrivilege'  => 'UnicaenAuth\Service\CategoriePrivilegeService',
        ],
        'abstract_factories' => [
            'UnicaenAuth\Authentication\Adapter\AbstractFactory',
        ],
        'factories'          => [
            'unicaen-auth_module_options'              => 'UnicaenAuth\Options\ModuleOptionsFactory',
            'zfcuser_auth_service'                     => 'UnicaenAuth\Authentication\AuthenticationServiceFactory',
            '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',
            'UnicaenAuth\Provider\Identity\Basic'      => 'UnicaenAuth\Provider\Identity\BasicServiceFactory',
            'UnicaenAuth\Provider\Role\Config'         => 'UnicaenAuth\Provider\Role\ConfigServiceFactory',
            'UnicaenAuth\Provider\Role\DbRole'         => 'UnicaenAuth\Provider\Role\DbRoleServiceFactory',
            'UnicaenAuth\Provider\Role\Username'       => 'UnicaenAuth\Provider\Role\UsernameServiceFactory',
Bertrand Gauthier's avatar
Bertrand Gauthier committed
449
450
            'UnicaenAuth\Service\Role'                 => 'UnicaenAuth\Service\RoleServiceFactory',
            'UnicaenAuth\Service\Privilege'            => 'UnicaenAuth\Service\PrivilegeServiceFactory',
451
452
            'BjyAuthorize\Service\Authorize'           => 'UnicaenAuth\Service\AuthorizeServiceFactory', // substituion
            'zfcuser_redirect_callback'                => 'UnicaenAuth\Authentication\RedirectCallbackFactory', // substituion
453
            ShibService::class                         => ShibServiceFactory::class,
454
            'UnicaenAuth\Service\UserContext'          => UserContextFactory::class,
455
            'zfcuser_user_mapper'                      => UserMapperFactory::class,
456
            'MouchardCompleterAuth'        => 'UnicaenAuth\Mouchard\MouchardCompleterAuthFactory',
457
458
459
460
461
462
            'UnicaenAuth\Authentication\Storage\Db'   => DbFactory::class,
            'UnicaenAuth\Authentication\Storage\Ldap' => LdapFactory::class,
            'UnicaenAuth\Authentication\Storage\Shib' => ShibFactory::class,
            'UnicaenAuth\Service\User'                => UserFactory::class,
            'UnicaenAuth\Guard\PrivilegeController'   => PrivilegeControllerFactory::class,
            'UnicaenAuth\Guard\PrivilegeRoute'        => PrivilegeRouteFactory::class,
463
464
465
        ],
        'shared' => [
            'MouchardCompleterAuth'        => false,
466
467
468
469
470
471
472
473
474
        ],
        'initializers'       => [
            'UnicaenAuth\Service\UserAwareInitializer',
        ],
    ],

    'controllers'   => [
        'invokables' => [
        ],
475
476
        'factories' => [
            'UnicaenAuth\Controller\Auth'        => AuthControllerFactory::class,
477
478
            'UnicaenAuth\Controller\Utilisateur' => UtilisateurControllerFactory::class,
            'UnicaenAuth\Controller\Droits'      => DroitsControllerFactory::class,
479
        ],
480
481
482
483
    ],

    'form_elements' => [
        'invokables' => [
484
485
486
        ],
        'factories' => [
            'UnicaenAuth\Form\Droits\Role' => RoleFormFactory::class,
487
488
        ],
    ],
489

490
    'view_helpers'  => [
491
492
493
494
495
496
497
498
        'factories'  => [
            'userConnection'             => 'UnicaenAuth\View\Helper\UserConnectionFactory',
            'userCurrent'                => 'UnicaenAuth\View\Helper\UserCurrentFactory',
            'userStatus'                 => 'UnicaenAuth\View\Helper\UserStatusFactory',
            'userProfile'                => 'UnicaenAuth\View\Helper\UserProfileFactory',
            'userInfo'                   => 'UnicaenAuth\View\Helper\UserInfoFactory',
            'userProfileSelect'          => 'UnicaenAuth\View\Helper\UserProfileSelectFactory',
            'userProfileSelectRadioItem' => 'UnicaenAuth\View\Helper\UserProfileSelectRadioItemFactory',
499
            'userUsurpation'             => UserUsurpationHelperFactory::class,
500
            'localConnect'               => LocalConnectViewHelperFactory::class,
501
            'ldapConnect'                => LdapConnectViewHelperFactory::class,
502
            'shibConnect'                => ShibConnectViewHelperFactory::class,
503
504
505
506
507
        ],
        'invokables' => [
            'appConnection' => 'UnicaenAuth\View\Helper\AppConnection',
        ],
    ],
508
];