From f624fd8ad917c3f2836aed7fc57415d9602cc24d Mon Sep 17 00:00:00 2001 From: David Lambauer Date: Wed, 19 Jul 2023 16:19:44 +0200 Subject: [PATCH] Add acl.md. --- acl.md | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 acl.md diff --git a/acl.md b/acl.md new file mode 100644 index 0000000..5d844c3 --- /dev/null +++ b/acl.md @@ -0,0 +1,121 @@ +# ACL XML Reference Documentation + +This reference documentation provides information on the structure and usage of the acl.xml file in Magento 2. acl.xml is an essential configuration file used to define Access Control List (ACL) permissions for various resources in your Magento 2 module or extension. + +## 1. Introduction + +Access Control List (ACL) is a security mechanism used to control access to resources based on user roles and permissions. The acl.xml file is used in Magento 2 to define these roles, resources, and associated permissions for your module or extension. + +## 2. Structure of acl.xml + +The acl.xml file follows a specific structure and should be placed in the `etc` directory of your module or extension. Here is an example of the basic structure of acl.xml: + +```xml + + + + + +``` + +The `xmlns:xsi` and `xsi:noNamespaceSchemaLocation` attributes define the XML schema for validation. The `` tag is the root element, under which you define resources and roles. + +## 3. Defining Resources and Roles + +In the `` tag, you define `` and `` elements to specify the resources and roles respectively. A resource represents a specific functionality or area in your module or extension, while a role represents a user role or group. + +Here is an example of defining a resource and a role in acl.xml: + +```xml + + + + + + + + + + + + + + + +``` + +In the above example, the `` element defines a resource with an `id`, `title`, and `sortOrder`. The `id` should follow the format `::`. Similarly, the `` element defines a role with an `id`, `title`, and `sortOrder`. + +## 4. Applying ACL Permissions + +Once you have defined resources and roles, you need to specify the permissions or access rules for each role on the respective resources. For this, you use the `` and `` elements. + +Here is an example of applying ACL permissions in acl.xml: + +```xml + + + + + + + + + + + + + + + + + + + + + +``` + +In the above example, the `` element is nested under the appropriate `` and ``. The `id` attribute follows the format `::`. The `title` attribute provides a human-readable title for the permission. + +## 5. Examples + +Here are a few examples to illustrate how to define resources, roles, and apply ACL permissions in acl.xml: + +### Example 1: Defining a Resource + +```xml + + + + + +``` + +### Example 2: Defining a Role + +```xml + + + + + +``` + +### Example 3: Applying Permissions to a Role + +```xml + + + + + + + + + +``` + +## Conclusion + +The acl.xml file is a crucial configuration file in Magento 2 for defining Access Control List (ACL) permissions. By understanding its structure and usage, you can control access to resources based on user roles and permissions effectively.