Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arobases-sylius-plugins/arobasessyliusrightsmanagementplugin
Rights and roles management for Sylius
https://github.com/arobases-sylius-plugins/arobasessyliusrightsmanagementplugin
management php right sylius sylius-plugin symfony
Last synced: 9 days ago
JSON representation
Rights and roles management for Sylius
- Host: GitHub
- URL: https://github.com/arobases-sylius-plugins/arobasessyliusrightsmanagementplugin
- Owner: Arobases-Sylius-Plugins
- Created: 2022-03-18T19:47:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-01T14:44:23.000Z (about 2 months ago)
- Last Synced: 2024-10-27T21:15:23.088Z (21 days ago)
- Topics: management, php, right, sylius, sylius-plugin, symfony
- Language: PHP
- Homepage:
- Size: 246 KB
- Stars: 0
- Watchers: 0
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Arobases Sylius Rights Management Plugin
This plugin allows you to manage the rights and roles of administrator users
![arobases_banner](https://user-images.githubusercontent.com/39689570/219030936-8649849f-11a4-4533-bd5d-6f79662aca87.jpg)
Installation
### Step 1: Download the plugin
* Install the plugin with `composer require arobases/sylius-rights-management-plugin`
### Step 2: Enable the plugin
* Register the bundle in your `bundles.php`:
```bash
# config/bundles.php
['all' => true],
...
];
```### Step 3: Import configuration
Create file `config/packages/arobases_sylius_rights_management_plugin.yaml` with this content
```
imports:
- { resource: "@ArobasesSyliusRightsManagementPlugin/Resources/config/config.yaml" }
```
### Step 4: Import routingCreate file `config/routes/arobases_sylius_rights_management_plugin.yaml` with this content
```
arobases_sylius_rights_management_plugin_admin:
resource: "@ArobasesSyliusRightsManagementPlugin/Resources/config/admin_routing.yml"
prefix: /admin
```### Step 5: Use AdminUserTrait and implement AdminUserInterface
```php
//src/Entity/AdminUser.php
{{ 'arobases_sylius_rights_management_plugin.ui.choice_role'|trans }}
{{ form_row(form.role) }}
...
```
### Step 7: Update your database:```
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
```
### Step 8: Install assets```
php bin/console asset:install
php bin/console cache:clear
```### Step 9: Define your default role (for example "administrator") and the username of the admin account which will have this role by default
```env
#.env###> arobases/sylius-rights-management ###
DEFAULT_ADMIN_USER=EDITME
DEFAULT_ADMIN_ROLE_CODE=EDITME
DEFAULT_ADMIN_ROLE_NAME=EDITME
###> arobases/sylius-rights-management ###```
if you don't change this lines, when you will create the rights with the command, you will no longer have access to anything in the back office because you will not have the rights.### Step 10: Use the command line to create roles, rights group and rights :
```
php bin/console arobases:right:create-admin-right
```### Screenshots
Index
![role_index](https://user-images.githubusercontent.com/39689570/219010702-9d01edba-bc4b-4772-88f6-ef2ca85db530.png)
Edit/create role
![role_update](https://user-images.githubusercontent.com/39689570/219010777-4b8d00d1-6553-4836-959f-5491883f15a7.png)
![role_update2](https://user-images.githubusercontent.com/39689570/219010876-bb5e3fe1-df3e-411c-b58a-6451139e6a71.png)
Error if the user does not have the rights
![access_denied](https://user-images.githubusercontent.com/39689570/219026995-3a37f643-0e10-4637-a40c-70c49077a770.png)
### Usage
There is a pre-configured list of default rights :
```yaml
#vendor/arobases/sylius-rights-management-plugin/src/Resources/config/right_management.yamlarobases_sylius_rights_management:
groups:
arobases_sylius_rights_management_plugin.group.taxon: #here it's the name of the group of the right
rights:
all:
name: 'arobases_sylius_rights_management_plugin.rights.taxon' #here it's the name of the right
routes: ['sylius_admin_taxon_*', 'sylius_admin_ajax_generate_taxon_slug']arobases_sylius_rights_management_plugin.group.product:
rights:
product:
name: 'arobases_sylius_rights_management_plugin.rights.product'
routes: ['sylius_admin_product_*', 'sylius_admin_get_product_attributes_*', 'sylius_admin_get_attribute_types', 'sylius_admin_ajax_generate_product_slug', 'sylius_admin_ajax_taxon_*', 'sylius_admin_ajax_product_*' ]
stock:
name: 'arobases_sylius_rights_management_plugin.rights.inventory'
routes: ['sylius_admin_inventory_*']arobases_sylius_rights_management_plugin.group.order:
rights:
all:
name: 'arobases_sylius_rights_management_plugin.rights.order'
routes: ['sylius_admin_order_*', 'sylius_admin_payment_*', 'sylius_admin_shipment_*','sylius_invoicing_plugin_admin_invoice_*', 'sylius_refund_*', 'sylius_admin_ajax_render_province_*']
excludes: ['sylius_admin_payment_method_*']
arobases_sylius_rights_management_plugin.group.promotion:
rights:
all:
name: 'arobases_sylius_rights_management_plugin.rights.promotion'
routes: ['sylius_admin_promotion_*']
arobases_sylius_rights_management_plugin.group.user:
rights:
user:
name: 'arobases_sylius_rights_management_plugin.rights.customer'
routes: ['sylius_admin_customer_*', 'sylius_admin_impersonate_*']
excludes: ['sylius_admin_customer_group_*']
group:
name: 'sylius.ui.customer_groups'
routes: ['sylius_admin_customer_group_*',]arobases_sylius_rights_management_plugin.group.configuration:
rights:
channel:
name: 'arobases_sylius_rights_management_plugin.rights.channel'
routes: ['sylius_admin_channel_*']
country:
name: 'arobases_sylius_rights_management_plugin.rights.country'
routes: ['sylius_admin_country_*']
zone:
name: 'arobases_sylius_rights_management_plugin.rights.zone'
routes: ['sylius_admin_zone_*']
currency:
name: 'arobases_sylius_rights_management_plugin.rights.currency'
routes: ['sylius_admin_currency_*']
exchange_rate:
name: 'arobases_sylius_rights_management_plugin.rights.exchange_rate'
routes: ['sylius_admin_exchange_rate_*']
locale:
name: 'arobases_sylius_rights_management_plugin.rights.locale'
routes: ['sylius_admin_locale_*']
payment_method:
name: 'arobases_sylius_rights_management_plugin.rights.payment_method'
routes: ['sylius_admin_payment_method_*', 'sylius_admin_get_payment_gateways']
shipping_method:
name: 'arobases_sylius_rights_management_plugin.rights.shipping_method'
routes: ['sylius_admin_shipping_method_*', 'webgriffe_admin_shipping_table_rate_*']
shipping_category:
name: 'arobases_sylius_rights_management_plugin.rights.shipping_category'
routes: ['sylius_admin_shipping_category_*']
tax_category:
name: 'arobases_sylius_rights_management_plugin.rights.tax_category'
routes: ['sylius_admin_tax_category_*']
tax_rate:
name: 'arobases_sylius_rights_management_plugin.rights.tax_rate'
routes: ['sylius_admin_tax_rate_*']
arobases_sylius_rights_management_plugin.group.administration:
rights:
admin_user:
name: 'arobases_sylius_rights_management_plugin.rights.admin_user'
routes: ['sylius_admin_admin_user_*']
admin_role:
name: 'arobases_sylius_rights_management_plugin.rights.admin_role'
routes: ['arobases_sylius_rights_management_plugin_admin_role_*']
```
However you can modify or add some rights or rights group in your file config/packages/arobases_sylius_rights_management_plugin.yaml :
```yaml
#config/packages/arobases_sylius_rights_management_plugin.yamlimports:
- { resource: "@ArobasesSyliusRightsManagementPlugin/Resources/config/resources.yaml" }arobases_sylius_rights_management:
groups:
arobases_sylius_rights_management_plugin.group.product:
rights:
#here you will update "arobases_sylius_rights_management_plugin.group.product"app.group.my_new_group:
rights:
all:
name: 'app.rights.my_new_right'
routes: ['app_my_custom_route_*']
#here you will create a new group and a new right
```