Reference

Authorization adapters

You can configure the authorization adapter to use via your service container configuration. Specifically, you can either map the service name Mezzio\Authorization\AuthorizationInterface to a factory, or alias it to the appropriate service.

For instance, using Mezzio container configuration, you could select the mezzio-authorization-acl adapter in either of the following ways:

  • Using an alias:

    use Mezzio\Authorization\AuthorizationInterface;
    use Mezzio\Authorization\Acl\LaminasAcl;
    
    return [
        'dependencies' => [
            // Using an alias:
            'aliases' => [
                AuthorizationInterface::class => LaminasAcl::class,
            ],
        ],
    ];

  • Mapping to a factory:

    use Mezzio\Authorization\AuthorizationInterface;
    use Mezzio\Authorization\Acl\LaminasAclFactory;
    
    return [
        'dependencies' => [
            // Using a factory:
            'factories' => [
                AuthorizationInterface::class => LaminasAclFactory::class,
            ],
        ],
    ];

We provide two different adapters.

Each adapter is installable via Composer:

$ composer require mezzio/mezzio-authorization-rbac
# or
$ composer require mezzio/mezzio-authorization-acl

In each adapter, we use the route name as the resource. This means you can specify if a role is authorized to access a specific HTTP route. However, this is just one approach to implementing an authorization system; you can create your own system by implementing the AuthorizationInterface.

For more information on the adapters, please read the RBAC documentation and the ACL documentation.

Found a mistake or want to contribute to the documentation? Edit this page on GitHub!