Download the PHP package mimmi20/mezzio-generic-authorization without Composer
On this page you can find all versions of the php package mimmi20/mezzio-generic-authorization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mimmi20/mezzio-generic-authorization
More information about mimmi20/mezzio-generic-authorization
Files in mimmi20/mezzio-generic-authorization
Package mezzio-generic-authorization
Short Description Provides a Authorization middleware for Mezzio and PSR-7 applications.
License MIT
Homepage https://github.com/mimmi20/mezzio-generic-authorization
Informations about the package mezzio-generic-authorization
mezzio-generic-authorization
Code Status
Installation
You can install the mezzio-generic-authorization library with Composer:
Introduction
This component provides middleware for Mezzio and PSR-7 applications for authorizing specific routes based on ACL or RBAC systems.
Unlike in mezzio-authorization this library does not require
the ServerRequestInterface
by default. This makes it possible to use this component in combination with mezzio-navigation.
If you are using the provided midleware, the route name is used as the resource.
An authorization system first needs authentication: to verify that an identity has access to something (i.e., is authorized) we first need the identity, which is provided during authentication.
Authentication is provided via the package
mezzio-authentication.
That library provides an AuthenticationMiddleware
class that verify
credentials using the HTTP request, and stores the identity via a
PSR-7 request attribute.
The identity generated by mezzio-authentication is stored as the
request attribute Mezzio\Authentication\UserInterface
as a
UserInterface
implementation. That interface looks like the following:
mezzio-generic-authorization consumes this identity attribute. It checks if a
user's role (as retrieved from the UserInterface
object) is authorized
(granted) to the perform the current HTTP request.
Authorization is performed using the isGranted()
method of the AuthorizationInterface
Two adapters are available:
- mezzio-generic-authorization-rbac, which implements Role-Based Access Controls (RBAC)
- mezzio-generic-authorization-acl, which implements an Access Control List (ACL).
If you want to know more about authentication using middleware in PHP, we suggest reading the blog post "Authorize users using Middleware".
Authorization adapters
You can configure the authorization adapter to use via your service container
configuration. Specifically, you can either map the service name
Mimmi20\Mezzio\GenericAuthorization\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:
- Mapping to a factory:
We provide two different adapters.
- The RBAC adapter is provided by mezzio-generic-authorization-rbac.
- The ACL adapter is provided by mezzio-generic-authorization-acl.
Each adapter is installable via Composer:
License
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.
All versions of mezzio-generic-authorization with dependencies
mezzio/mezzio-authentication Version ^1.9.0
mezzio/mezzio-router Version ^3.17.0
psr/container Version ^1.1.2 || ^2.0.2
psr/http-factory Version ^1.1.0
psr/http-message Version ^1.0.1 || ^2.0
psr/http-server-handler Version ^1.0.2
psr/http-server-middleware Version ^1.0.2