unicaen-auth.global.php.dist 6.32 KB
Newer Older
Bertrand Gauthier's avatar
Bertrand Gauthier committed
1
2
<?php
/**
3
 * UnicaenAuth Global Configuration
Bertrand Gauthier's avatar
Bertrand Gauthier committed
4
5
6
7
 *
 * If you have a ./config/autoload/ directory set up for your project, you can
 * drop this config file in it and change the values as you wish.
 */
8
$settings = [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
9
10
11
12
    /**
     * Flag indiquant si l'utilisateur authenitifié avec succès via l'annuaire LDAP doit
     * être enregistré/mis à jour dans la table des utilisateurs de l'appli.
     */
Bertrand Gauthier's avatar
Bertrand Gauthier committed
13
    'save_ldap_user_in_database' => false,
Bertrand Gauthier's avatar
Bertrand Gauthier committed
14
    /**
15
16
17
     * Enable registration
     * Allows users to register through the website.
     * Accepted values: boolean true or false
Bertrand Gauthier's avatar
Bertrand Gauthier committed
18
     */
19
20
    'enable_registration'        => false,

21
22
    'enable_privileges' => true,

23
];
Bertrand Gauthier's avatar
Bertrand Gauthier committed
24

25
$config = [
Bertrand Gauthier's avatar
Bertrand Gauthier committed
26
    'unicaen-auth' => $settings,
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    '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.
                 *
                 * 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'    => [
            /**
             * 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'   => [],
            /**
             * 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' => [],
        ],
55
56
57
58
59
    ],
    'zfcuser'      => [
        $k = 'enable_registration' => isset($settings[$k]) ? $settings[$k] : false,
    ],
];
60

61
62
63
64
65
66
67
68
69
70
71
if ($settings['enable_privileges']) {
    $privileges = [
        'bjyauthorize' => [

            'resource_providers' => [
                /**
                 * Le service Privilèges peut aussi être une source de ressources,
                 * si on souhaite tester directement l'accès à un privilège
                 */
                'UnicaenAuth\Service\Privilege' => [],
            ],
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
99
100
101
102
103
104
105
            'rule_providers'     => [
                'UnicaenAuth\Provider\Rule\PrivilegeRuleProvider' => [],
            ],

            'guards' => [
                'UnicaenAuth\Guard\PrivilegeController' => [
                    [
                        'controller' => 'UnicaenAuth\Controller\Droits',
                        'action'     => ['index'],
                        'privileges' => [
                            \UnicaenAuth\Provider\Privilege\Privileges::DROIT_ROLE_VISUALISATION,
                            \UnicaenAuth\Provider\Privilege\Privileges::DROIT_PRIVILEGE_VISUALISATION,
                        ],
                    ],
                    [
                        'controller' => 'UnicaenAuth\Controller\Droits',
                        'action'     => ['roles'],
                        'privileges' => [\UnicaenAuth\Provider\Privilege\Privileges::DROIT_ROLE_VISUALISATION],
                    ],
                    [
                        'controller' => 'UnicaenAuth\Controller\Droits',
                        'action'     => ['privileges'],
                        'privileges' => [\UnicaenAuth\Provider\Privilege\Privileges::DROIT_PRIVILEGE_VISUALISATION],
                    ],
                    [
                        'controller' => 'UnicaenAuth\Controller\Droits',
                        'action'     => ['role-edition', 'role-suppression'],
                        'privileges' => [\UnicaenAuth\Provider\Privilege\Privileges::DROIT_ROLE_EDITION],
                    ],
                    [
                        'controller' => 'UnicaenAuth\Controller\Droits',
                        'action'     => ['privileges-modifier'],
                        'privileges' => [\UnicaenAuth\Provider\Privilege\Privileges::DROIT_PRIVILEGE_EDITION],
106
107
108
109
                    ],
                ],
            ],
        ],
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
        'navigation'   => [
            // The DefaultNavigationFactory we configured uses 'default' as the sitemap key
            'default' => [
                // And finally, here is where we define our page hierarchy
                'home' => [
                    'pages' => [
                        'droits' => [
                            'label'    => 'Droits d\'accès',
                            'title'    => 'Gestion des droits d\'accès',
                            'route'    => 'droits',
                            'resource' => \UnicaenAuth\Guard\PrivilegeController::getResourceId('UnicaenAuth\Controller\Droits', 'index'),
                            'pages'    => [
                                'roles'      => [
                                    'label'      => "Rôles",
                                    'title'      => "Gestion des rôles",
                                    'route'      => 'droits/roles',
                                    'resource'   => \UnicaenAuth\Guard\PrivilegeController::getResourceId('UnicaenAuth\Controller\Droits', 'roles'),
                                    'withtarget' => true,
                                ],
                                'privileges' => [
                                    'label'      => "Privilèges",
                                    'title'      => "Gestion des privilèges",
                                    'route'      => 'droits/privileges',
                                    'resource'   => \UnicaenAuth\Guard\PrivilegeController::getResourceId('UnicaenAuth\Controller\Droits', 'privileges'),
                                    'withtarget' => true,
                                ],
136
137
138
139
140
141
                            ],
                        ],
                    ],
                ],
            ],
        ],
142
143
144
145
146
147
    ];
} else {
    $privileges = [];
}

return array_merge_recursive($config, $privileges);