Download the PHP package sylius/rbac-plugin without Composer

On this page you can find all versions of the php package sylius/rbac-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rbac-plugin

Rbac Plugin

This plugin provides basic roles and permissions management functionality for Sylius application.

Beware!

Adding Write access to a permission automatically means adding Read access.

Write permission access means also updating and deleting.

Installation

  1. Require plugin with composer:

  2. Add plugin class and ProophServiceBusBundle to your bundles.php.

  3. Override AdminUser entity:

a) Use AdministrationRoleAwareTrait and implement AdministrationRoleAwareInterface in the AdminUser class of your Sylius-Standard based project:

b) And override the model's class in the chosen configuration file (e.g. config/_sylius.yaml):

  1. Import routing in config/routes/sylius_rbac.yaml:

  2. Import configuration in config/packages/sylius_rbac.yaml:

  3. Copy plugin migrations to your migrations directory (e.g. src/Migrations) and apply them to your database:

  4. Copy overwritten SyliusAdminBundle templates:

  5. Run installation command

    Which consists of:

    • sylius:fixtures:load

      Loading fixture with a default "No sections access" role.

      The command runs in non-interactive mode so it will NOT purge your database. However, once you run it again it will throw an exception because of duplicate entry constraint violation.

      If you want to install RBAC plugin again on the same environment you will have to remove all roles manually via administration panel or run all commands except sylius:fixtures:load separately.

    • sylius-rbac:normalize-administrators

      Assigns role created in a previous step to all already existent administrators.

    • sylius-rbac:grant-access <roleName> <adminSections>

      Where adminSections can be a space-separated list of any of these:

      • catalogManagement
      • configuration
      • customerManagement
      • marketingManagement
      • salesManagement

      Beware!

      There are two ways of defining root administrator's email address:

      • Provide it as a parameter in your configuration file (you will not be asked to enter it again via CLI during plugin's installation)

      • Provide it via CLI

      e.g. bin/console sylius-rbac:grant-access administrator configuration catalogManagement

      In order to permit access to admin panel sections, please provide administrator's email address: [email protected]

      By default, installation command creates Configurator role with access granted to all sections.

Beware!

You can also use bin/console sylius-rbac:grant-access-to-given-administrator <email> <roleName> <adminSections> command in order to provide an email address as an input parameter.

Beware!

AdminUser entity references AdministrationRoleInterface, which is an abstraction layer above the default AdministrationRole implementation. You can easily customize it by adding a following snippet in your *.yaml configuration file:

Sections configuration

By default, RbacPlugin is provided with access configuration for basic Sylius sections (catalog, configuration, customers, marketing and sales) as well as for RBAC section, added by the plugin itself. Each section has a bunch of route prefixes associated with them, that describes which section gives permissions to which resources management.

However, usually, a Sylius application has a plenty of custom functions within existing or entirely new sections. This plugin allows you to extend its configuration, in order to restrict access to these custom routes.

For the matter of example let's assume we have a simple Supplier resource (containing only string $name property). It also has already generated routes, that we would like to restrict access to:

If you don't know how to create and configure custom resource in Sylius application, check out relevant documentation chapter.

Extending basic Sylius section with new route prefixes

The only thing required to restrict Supplier-related routes with, for example, "Customer management" permission, is adding appropriate route prefix to customers section configuration:

You would probably also want to add extend "Customers" section in Admin main menu (take a look at this docs chapter for more information).

As a result, each Administrator allowed to manage customers in the Admin panel would also be able to manage Suppliers. You may also notice, nothing has changed in permissions configuration form, as no new section has been added to the RBAC configuration.

Adding a custom section to the application

What if you want to differentiate your new resources management permission? The other possibility is to define your own, custom section in a plugin configuration:

Curiosity: RBAC is also defined as a custom section! You can easily check it out in a plugin source code.

With such a configuration, you should notice a new permission configuration available in the Administration Role form.

To display new permission name nicely, you should also configure a translation in your application's translation file:

Beware!

You should take into account that by default the RBAC Plugin recognizes the admin-related routes using logic placed in the HardcodedRouteNameChecker class, which is the following:

Let's assume that you added a new route to your application and you want it to be handled by the RBAC plugin. Once you did so, you should override the checker placed above and customize it in the following manner:

Remember!

When configuring a custom section in Admin main menu, name it the same way you named it under custom_sections key in the plugin configuration. It will be automatically hidden and shown, exactly as basic Sylius sections!

After these few simple steps, you can already give your custom permission to any already existent Administration role.

Security issues

If you think that you have found a security issue, please do not use the issue tracker and do not post it publicly. Instead, all security issues must be sent to [email protected].


All versions of rbac-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
sylius/sylius Version ^1.4
prooph/service-bus-symfony-bundle Version ^0.7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sylius/rbac-plugin contains the following files

Loading the files please wait ....