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

3
use UnicaenAuth\Authentication\Storage\ShibSimulatorStorage;
4
5
6
use UnicaenAuth\Controller\AuthControllerFactory;
use UnicaenAuth\Service\ShibService;
use UnicaenAuth\Service\ShibServiceFactory;
7
use UnicaenAuth\Service\UserContextFactory;
8
use UnicaenAuth\View\Helper\LdapConnectViewHelperFactory;
9
use UnicaenAuth\View\Helper\ShibConnectViewHelperFactory;
10
use UnicaenAuth\View\Helper\UserUsurpationHelperFactory;
11

12
$settings = [
13
14
15
16
17
18
19
20
21
22
23

    /**
     * Configuration de l'authentification LDAP.
     */
    'ldap' => [
        /**
         * Possibilité ou non de s'authentifier via l'annuaire LDAP.
         */
        'enabled' => true,
    ],

24
25
26
    /**
     * Fournisseurs d'identité.
     */
27
    'identity_providers'  => [
28
29
        300 => 'UnicaenAuth\Provider\Identity\Basic', // en 1er
        200 => 'UnicaenAuth\Provider\Identity\Db',    // en 2e
30
        100 => 'UnicaenAuth\Provider\Identity\Ldap',  // en 3e @deprecated
31
    ],
32
33
34
35
36

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

39
40
return [
    'zfcuser'         => [
41
        /**
42
43
44
         * Enable registration
         * Allows users to register through the website.
         * Accepted values: boolean true or false
45
         */
46
        'enable_registration'     => true,
47
        /**
48
49
50
51
52
         * 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
53
         */
54
55
56
57
58
59
60
61
        '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',
62
        /**
63
64
65
66
         * 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
67
         */
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
        '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,
99
    ],
100
    'bjyauthorize'    => [
101

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
        /* 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
125
         */
126
127
128
129
130
131
132
133
134
        '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' => []],
135

136
137
138
139
140
141
142
143
                ['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' => []],
144
145

                ['controller' => 'UnicaenAuth\Controller\Auth', 'action' => 'shibboleth', 'roles' => []],
146
            ],
147
148
        ],
    ],
149
150
    'unicaen-auth'    => $settings,
    'doctrine'        => [
151
        'driver' => [
152
            // overriding zfc-user-doctrine-orm's config
153
            'zfcuser_entity'  => [
154
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
155
                'paths' => [
156
157
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db',
                ],
158
159
            ],
            'orm_auth_driver' => [
160
161
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
162
                'paths' => [
163
164
                    __DIR__ . '/../src/UnicaenAuth/Entity/Db',
                ],
165
            ],
166
            'orm_default'     => [
167
                'class'   => 'Doctrine\ORM\Mapping\Driver\DriverChain',
168
                'drivers' => [
169
                    'UnicaenAuth\Entity\Db' => 'zfcuser_entity',
170
171
                    'UnicaenAuth\Entity\Db' => 'orm_auth_driver',
                ],
172
173
174
            ],
        ],
    ],
175
176
    'view_manager'    => [
        'template_map'        => [
177
            'error/403' => __DIR__ . '/../view/error/403.phtml',
178
179
        ],
        'template_path_stack' => [
180
            'unicaen-auth' => __DIR__ . '/../view',
181
182
        ],
    ],
183
    'translator'      => [
184
185
        'translation_file_patterns' => [
            [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
186
187
188
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
189
190
191
            ],
        ],
    ],
192
    'router'          => [
193
        'routes' => [
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
            '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',
                            ],
                        ],
                    ],
                ],
            ],
215
216
217
218
219
            'zfcuser'     => [
                'type'          => 'Literal',
                'priority'      => 1000,
                'options'       => [
                    'route'    => '/auth',
220
                    'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
221
222
                        'controller' => 'zfcuser',
                        'action'     => 'index',
223
224
                    ],
                ],
Bertrand Gauthier's avatar
Bertrand Gauthier committed
225
                'may_terminate' => true,
226
227
228
                'child_routes'  => [
                    'login'    => [
                        'type'    => 'Literal',
229
                        'options' => [
230
                            'route'    => '/connexion',
231
                            'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
232
233
                                'controller' => 'zfcuser',
                                'action'     => 'login',
234
235
236
                            ],
                        ],
                    ],
237
238
                    'logout'   => [
                        'type'    => 'Literal',
239
                        'options' => [
240
                            'route'    => '/deconnexion',
241
                            'defaults' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
242
243
                                'controller' => 'zfcuser',
                                'action'     => 'logout',
244
245
246
247
                            ],
                        ],
                    ],
                    'register' => [
248
                        'type'    => 'Literal',
249
                        'options' => [
250
                            'route'    => '/creation-compte',
251
                            'defaults' => [
252
253
                                'controller' => 'zfcuser',
                                'action'     => 'register',
254
255
256
257
258
259
                            ],
                        ],
                    ],
                ],
            ],
            'utilisateur' => [
260
261
                'type'          => 'Literal',
                'options'       => [
262
                    'route'    => '/utilisateur',
263
                    'defaults' => [
264
265
266
                        '__NAMESPACE__' => 'UnicaenAuth\Controller',
                        'controller'    => 'Utilisateur',
                        'action'        => 'index',
267
268
                    ],
                ],
269
                'may_terminate' => true,
270
                'child_routes'  => [
271
                    'default' => [
272
                        'type'    => 'Segment',
273
                        'options' => [
274
                            'route'       => '/:action[/:id]',
275
                            'constraints' => [
276
277
                                'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                                'id'     => '[0-9]*',
278
                            ],
279
                            'defaults'    => [
280
                                'action' => 'index',
281
282
283
284
285
                            ],
                        ],
                    ],
                ],
            ],
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
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
            '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',
                                    ],
                                ],
                            ],
                        ],
                    ],
                ],
            ],
360
361
        ],
    ],
Bertrand Gauthier's avatar
Bertrand Gauthier committed
362
    // All navigation-related configuration is collected in the 'navigation' key
363
    'navigation'      => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
364
        // The DefaultNavigationFactory we configured uses 'default' as the sitemap key
365
        'default' => [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
366
            // And finally, here is where we define our page hierarchy
367
368
            'home' => [
                'pages' => [
369
370
371
372
                    'login'    => [
                        'label'   => _("Connexion"),
                        'route'   => 'zfcuser/login',
                        'visible' => false,
373
374
                    ],
                    'register' => [
375
                        'label'   => _("Enregistrement"),
Bertrand Gauthier's avatar
Bertrand Gauthier committed
376
377
                        'route'   => 'zfcuser/register',
                        'visible' => false,
378
379
380
381
382
                    ],
                ],
            ],
        ],
    ],
383
384
385
386
387
388
389
390
391
392
393
    '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\Authentication\Storage\Db'   => 'UnicaenAuth\Authentication\Storage\Db',
            'UnicaenAuth\Authentication\Storage\Ldap' => 'UnicaenAuth\Authentication\Storage\Ldap',
394
            'UnicaenAuth\Authentication\Storage\Shib' => 'UnicaenAuth\Authentication\Storage\Shib',
395
            'UnicaenAuth\Authentication\Storage\ShibSimulatorStorage' => ShibSimulatorStorage::class,
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
            'UnicaenAuth\View\RedirectionStrategy'    => 'UnicaenAuth\View\RedirectionStrategy',
            'UnicaenAuth\Service\User'                => 'UnicaenAuth\Service\User',
            '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
414
415
            'UnicaenAuth\Service\Role'                 => 'UnicaenAuth\Service\RoleServiceFactory',
            'UnicaenAuth\Service\Privilege'            => 'UnicaenAuth\Service\PrivilegeServiceFactory',
416
417
            'BjyAuthorize\Service\Authorize'           => 'UnicaenAuth\Service\AuthorizeServiceFactory', // substituion
            'zfcuser_redirect_callback'                => 'UnicaenAuth\Authentication\RedirectCallbackFactory', // substituion
418
            ShibService::class                         => ShibServiceFactory::class,
419
            'UnicaenAuth\Service\UserContext'          => UserContextFactory::class,
420
421
422
423
            'MouchardCompleterAuth'        => 'UnicaenAuth\Mouchard\MouchardCompleterAuthFactory',
        ],
        'shared' => [
            'MouchardCompleterAuth'        => false,
424
425
426
427
428
429
430
431
432
433
434
        ],
        'initializers'       => [
            'UnicaenAuth\Service\UserAwareInitializer',
        ],
    ],

    'controllers'   => [
        'invokables' => [
            'UnicaenAuth\Controller\Utilisateur' => 'UnicaenAuth\Controller\UtilisateurController',
            'UnicaenAuth\Controller\Droits'      => 'UnicaenAuth\Controller\DroitsController',
        ],
435
436
437
        'factories' => [
            'UnicaenAuth\Controller\Auth'        => AuthControllerFactory::class,
        ],
438
439
440
441
442
443
444
    ],

    'form_elements' => [
        'invokables' => [
            'UnicaenAuth\Form\Droits\Role' => 'UnicaenAuth\Form\Droits\RoleForm',
        ],
    ],
445

446
    'view_helpers'  => [
447
448
449
450
451
452
453
454
        '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',
455
            'userUsurpation'             => UserUsurpationHelperFactory::class,
456
            'ldapConnect'                => LdapConnectViewHelperFactory::class,
457
            'shibConnect'                => ShibConnectViewHelperFactory::class,
458
459
460
461
462
        ],
        'invokables' => [
            'appConnection' => 'UnicaenAuth\View\Helper\AppConnection',
        ],
    ],
463
];