Date de publication: le mercredi 23 novembre 2011 à 20h29
Dernière modification: par Pascal BOYER le mercredi 23 novembre 2011 à 20h52
versions 4.x
The built-in access control mechanism of eZ Publish is based on roles and policies. A policy is a rule that grants access to a specific function or all functions of a module. The functions are assigned to the module's views and thus the access requirements for a view are controlled by the functions that are assigned to it.
Le
mécanisme de contrôle d'accès
intégré à eZ Publish est basé sur les rôles et les droits d'accès. Un droit d'accès est une règle octroyant l'accès à une fonction spécifique ou à toutes les fonction d'un
module
. Les fonctions sont assignées aux vues des modules, ce qui implique que les accès requis par une vue soient contrôlés par les fonctions qui lui (la vue) sont assignées.
The following code (taken from the eZ Publish source) shows how the function-view assignments of the "notification" module are specified in "kernel/notification/module.php".
Le code ci-dessous (tiré du code source d'eZ Publish) montre comment les fonctions de vue assignées au module
notification
sont spécifiées dans le fichier kernel/notification/module.php.
<?php $Module = array( "name" => "eZNotification", "variable_params" => true ); $ViewList = array(); $ViewList["settings"] = array( "functions" => array( 'use' ), "script" => "settings.php", 'ui_context' => 'administration', "default_navigation_part" => 'ezmynavigationpart', "params" => array( ), 'unordered_params' => array( 'offset' => 'Offset' ) ); $ViewList["runfilter"] = array( "functions" => array( 'administrate' ), "script" => "runfilter.php", 'ui_context' => 'administration', "default_navigation_part" => 'ezsetupnavigationpart', "params" => array( ) ); $ViewList["addtonotification"] = array( "functions" => array( 'use' ), "script" => "addtonotification.php", 'ui_context' => 'administration', "default_navigation_part" => 'ezcontentnavigationpart', "params" => array( 'ContentNodeID' ) ); $FunctionList['use'] = array( ); $FunctionList['administrate'] = array( ); ?>
As the code shows, there are three views and two functions assigned to them. While the "administrate" function is assigned to the "runfilter" view, the "use" function is assigned to the "addtonotification" and "settings" views.
Comme le montre le code, il y a trois vues et deux fonctions qui leur sont assignées. Alors que la fonction administrate est assignée à la vue runfilter, la fonction use est assignée aux vues addtonotification et settings.
Multiple function assignments / Assigner plusieurs fonctions
A view can have several functions assigned to it. From version 3.9.3, the system makes use of logical operators ("and", "or") within the function-view assignments. The following examples show how this works.
Il est possible d'assigner plusieurs fonctions à une vue. Depuis la version 3.9.3, le système utilise des opérateurs logiques (and et or) dans les assignations des fonctions de vue. Les exemples suivants illustrent ce fonctionnement.
Exemple 1
The "tipafriend" view of the "content" module has two functions assigned. The following code is taken from "kernel/content/module.php".
Il y a deux fonctions assignées à la vue
tipafriend
du module content. Le code ci-après est tiré du fichier kernel/content/module.php:
$ViewList['tipafriend'] = array( 'functions' => array( 'tipafriend', 'read' ), 'default_navigation_part' => 'ezcontentnavigationpart', 'script' => 'tipafriend.php', 'params' => array( 'NodeID' ) );
The code in this example specifies that a user must be granted access to both the "tipafriend" and "read" functions in order to use the "tipafriend" view (which is a part of the "content" module). Note that there is an alternate way of specifying this, refer to the example below.
Dans cet exemple, le code spécifie qu'un utilisateur doit avoir accès aux deux fonctions tipafriend et read afin de pouvoir utiliser la vue tipafriend (qui fait partie du module content). Retenez qu'il existe une alternative pour définir cela. Référez-vous à l'exemple ci-dessous:
... 'functions' => array( 'tipafriend and read' ), ...
Also, note that the "and" operator can be either "and" or "&&".
Retenez également que l'opérateur and peut être remplacé par &&.
Exemple 2
The "list" view of the "section" module has three functions assigned. The following code is taken from "kernel/section/module.php".
Il y a trois fonctions assignées à la vue
list
du module section. Le code ci-après est tiré du fichier kernel/section/module.php:
$ViewList['list'] = array( 'functions' => array( 'view or edit or assign' ), 'script' => 'list.php', 'default_navigation_part' => 'ezsetupnavigationpart', "unordered_params" => array( "offset" => "Offset" ), 'params' => array( ) );
The code above specifies that a user must be granted access to either the "view" or the "edit" or the "assign" function in order to use the "list" view (which is a part of the "section" module). Note that that the "or" operator can be either "or" or "||".
Le code ci-dessus spécifie qu'un utilisateur doit avoir accès à la fonctions view ou edit ou assign afin de pouvoir utiliser la vue list (qui fait partie du module section). Retenez également que l'opérateur or peut être remplacé par ||.
Missing functions / Fonctions manquantes
Some modules do not have functions (for example, this is true for the "search" and "collaboration" modules). If this is the case, granting users access to that module means that the users have access to all of the module's views.
Certains modules n'ont pas de fonction (c'est par exemple le cas des modules search et collaboration). Dans ce cas, accorder aux utilisateurs l'accès à ce module signifie que ces derniers auront accès à toutes les vues du module.
But in cases where a module has both views with functions assigned as well as views without functions assigned, only users with access to the entire module will have access to the views were no functions are assigned.
Mais dans le cas où un module possède à la fois des vues avec fonctions assignées et des vues sans fonction assignée, alors seuls les utilisateurs ayant accès à tout le module auront accès aux vues sans fonction assignée.
Additional notes for earlier versions / Notes supplémentaires pour les versions plus anciennes
In eZ Publish versions prior to 3.9.3 (except 3.8.9 and later versions of the 3.8 branch), granting access to a function of a module means that the user(s) will get access to the following:
Pour les versions antérieures à la version 3.9.3 (exceptée la version 3.8.9 et suivantes de la branche 3.8), autoriser l'accès à la fonction d'un module signifie que l'utilisateur aura accès:
-
Views that have the function assigned.
aux vues auxquelles la fonction est assignée, -
Views that do not have any functions assigned.
aux vues auxquelles n'est assignée aucune fonction.
For example, in eZ Publish version 3.9.2, there are no functions assigned to the "discountgroupview" view of the "shop" module. Anonymous users that have access to the "buy" function of the "shop" module can access the "discountgroupview" view (along with other views of the "shop" module that do not have any functions assigned to them). This was changed in versions 3.10.0 beta1, 3.9.3 and 3.8.9 because of security reasons. Refer to the release announcement for more information.
Dans la version 3.9.2 d'eZ Publish, par exemple, aucune fonction n'est assignée à la vue
discountgroupview
du module shop. Les utilisateurs anonymes ayant accès à la fonction buy du module shop peuvent également accéder à la vue discountgroupview (ainsi qu'aux autres vues du module shop auxquelles aucune fonction n'est assignée). Ceci a été modifié dans les versions 3.10.0 beta1, 3.9.3 et 3.8.9 pour des raisons de sécurité. Référez-vous à
l'annonce de la release
pour de plus amples informations.
In order to optimize the functionality of the access permissions when using earlier versions, it is best that modules either have views with functions assigned or views without functions assigned to them, but not both.
Afin d'optimiser, lorsque l'on utilise des versions antérieures, les fonctionnalités liées aux permissions d'accès, il est préférable que les modules aient soit des vues avec fonctions assignées soit des vues sans fonctions assignées, mais pas les deux à la fois.
Function limitations / Limitations de fonction
A policy (which grants access to a module's function) can be further restricted by function limitations. This can only be done if the function itself supports limitations. A function may support none, one or several limitations. The following code shows how the available limitations for the "diff", "hide" and "tipafriend" functions of the "content" module are specified in "kernel/content/module.php".
Un droit d'accès (autorisant l'accès à une fonction d'un module) peut être encore limité par le biais des limitations de fonction. Cependant, cela ne peut être mis en œuvre que si la fonction supporte des limitations. Une fonction peut supporter zéro, une ou plusieurs limitations. Le code ci-dessous montre comment sont définies les limitations possibles des fonctions diff, hide et tipafriend du module content dans le fichier kernel/content/module.php.
... $FunctionList['diff'] = array( 'Class' => $ClassID, 'Section' => $SectionID, 'Owner' => $Assigned, 'Node' => $Node, 'Subtree' => $Subtree); ... $FunctionList['hide'] = array( 'Subtree' => $Subtree ); ... $FunctionList['tipafriend'] = array(); ...
As the code shows, the "diff" function supports five limitations, the "hide" function supports one limitation and the "tipafriend" function supports no limitations. Refer to the "Access control" section of the "Concept and basics" chapter for an overview of the available function limitations.
Comme le montre ce code, la fonction diff supporte 5 limitations, la fonction hide en supporte une et la fonction tipafriend aucune. Référez-vous au document
Contrôl d'accès
de la section Concepts et bases pour une vue générale des limitations de fonction disponibles.
Commentaires














