Search by

odiseoteam / sylius-rbac-plugin

odiseo

Sylius roles and permissions management plugin

Package info

github.com/odiseoteam/SyliusRbacPlugin

Type:sylius-plugin

pkg:composer/odiseoteam/sylius-rbac-plugin

Statistics

Installs: 169 547

Dependents: 0

Suggesters: 0

Stars: 8

Open Issues: 0


README

Odiseo Sylius RBAC Plugin

Version Downloads Build status Sylius versions PHP version License

Introduction

This plugin adds role-based access control to the Sylius admin: you define your own roles, one permission per operation on one resource, and it enforces them everywhere.

What makes this plugin different?

  • ✅ One permission per operation - sylius.product.update and sylius.product.delete are separate permissions
  • ✅ Every admin route and API operation covered - Permissions come from Sylius' own resource metadata, so routes added by other plugins are covered automatically
  • ✅ Deny by default - An unprotected route is denied, not allowed. Exceptions are explicit, in config
  • ✅ UI filtered, not just routes - Menu entries, grid buttons and dashboard widgets check the same permission
  • ✅ Workflow transitions included - Cancelling an order asks for sylius.order.cancel, not sylius.order.update
  • ✅ Multiple roles per administrator - Roles are additive, with a lockout guard on the roles screen
  • ✅ Console tooling - Grant access, list permissions, find orphaned ones and migrate v2 data from the CLI
  • ✅ 18 locales - Including English, Spanish, French, German, Polish, Portuguese, Simplified Chinese and Arabic
Screenshots

The permission tree

Administration roles
Roles: The ones you define, not a fixed list
Assigning roles
Assignment: An administrator may hold several roles
Filtered menu
Menu: Trimmed to what the role can reach
Filtered grid actions
Grids: No Create, no Delete, for a role without them

Getting Started

Install it in 5 steps ⚡

  1. ✅ Require the plugin
  2. ✅ Wire the assets
  3. ✅ Make your AdminUser administration-role aware
  4. ✅ Update the database schema
  5. ✅ Give someone access

👉 Follow the installation guide

Quick Example

Require the plugin. Symfony Flex's recipe registers the bundle and imports its config and routes for you:

composer require odiseoteam/sylius-rbac-plugin --no-scripts

Once the remaining steps are done, grant the first role from the console:

bin/console odiseo:rbac:grant <username-or-email> super_admin --create

Important

An administrator with no role is denied everything, including the screen that assigns roles. Right after installing, nobody can reach the admin panel until you grant that first role.

What a permission looks like

Every permission is {package}.{subject}.{operation}, the same code Sylius' own resource metadata produces:

Pattern Meaning
sylius.product.update One operation on one resource
sylius.product.* Everything on products
sylius.order.ship An operation that is not CRUD
*.*.index A read-only role, across the whole application
*.*.* A super administrator

A role stores the pattern as written, not the list of operations it matches today, so sylius.product.* keeps working when Sylius adds a new operation to products later.

Learn more about the permission model →

Documentation

Compatibility

Plugin Sylius PHP Symfony Database
^3.0 2.0 · 2.1 · 2.2 8.2 · 8.3 · 8.4 6.4 · 7.x MySQL · MariaDB · PostgreSQL
^2.0 1.12 · 2.0 8.0+ 5.4 · 6.x MySQL · MariaDB

Note

The schema migrations ship for MySQL/MariaDB and PostgreSQL. On any other engine they skip, and Doctrine records them as executed even so, so write your own before upgrading a 2.x database, see Upgrading to 3.0.

Only the latest minor is supported. Security fixes land on master.

Professional Support

This plugin is maintained by Odiseo. Need help with it, or with any Sylius project?

License

MIT.