PHPackages                             alichry/laminas-authorization - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. alichry/laminas-authorization

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

alichry/laminas-authorization
=============================

Authorization for Laminas

0.4.2(5y ago)1251MITPHPPHP ^7.2CI failing

Since Jun 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/alichry/laminas-authorization)[ Packagist](https://packagist.org/packages/alichry/laminas-authorization)[ RSS](/packages/alichry-laminas-authorization/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (9)Versions (12)Used By (0)

laminas-authorization
=====================

[](#laminas-authorization)

[![Build Status](https://camo.githubusercontent.com/d2d4219c238712e8b3bca6e1c9ff5b62c45dc7eda2b56e03237d9730eb804c18/68747470733a2f2f7472617669732d63692e6f72672f616c69636872792f6c616d696e61732d617574686f72697a6174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alichry/laminas-authorization)[![codecov](https://camo.githubusercontent.com/5b69434fe0c0de4748be5d5ed1f79ea68b4338d9c63d14e7980539459088b0dc/68747470733a2f2f636f6465636f762e696f2f67682f616c69636872792f6c616d696e61732d617574686f72697a6174696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/alichry/laminas-authorization)

Out of the box, Laminas's authentication module provides interfaces and services for authenticating users and saving their identities in a session storage. This module provides an authorization service by transparently redirecting unauthorized users accessing a certain resource, with the support of defining multiple authorization links forming an authorization chain. You can configure the list of controller/method authorization statuses (policies) by creating annotations on top of your methods or setting it in the configuration.

Installation
------------

[](#installation)

Install using composer, run

```
$ composer require alichry/laminas-authorization

```

Add the modules `AliChry\Laminas\AccessControl` and `AliChry\Laminas\Authorization`to `config/modules.config.php`

Prerequisites
-------------

[](#prerequisites)

This module is not concerned with authenticating users, rather, its only intent is to check the authorization status of the (authenticated) identity. To create an authorization link, we require:

- An [`AuthenticationServiceInterface`](https://github.com/laminas/laminas-authentication): You can use [doctrine/doctrine-module](https://github.com/doctrine/DoctrineModule)to configure an authentication service easily.
- An [`AccessControlListInterface`](https://github.com/alichry/accesscontrol): [alichry/laminas-accesscontrol](https://github.com/alichry/laminas-accesscontrol)provides configurable services. By default, this module configures an [`IdentityAccessControlList`](https://github.com/alichry/laminas-authorization/blob/master/config/module.config.php)instance using [`AnnotatedResourceManager`](https://github.com/alichry/laminas-authorization/blob/master/src/Resource/AnnotatedResourceManager.php)as a dependency alongside passed identities implementing [`IdentityInterface`](https://github.com/alichry/laminas-accesscontrol/blob/master/src/Identity/IdentityInterface.php).

Quick start
-----------

[](#quick-start)

The fastest path to create a Laminas application with authorization support is through Doctrine ORM integration. If you're unfamiliar with Doctrine ORM, please check the doctrine project website and [doctrine/doctrine-orm-module](https://github.com/doctrine/DoctrineORMModule)

- Let your identity type class implement [`IdentityInterface`](https://github.com/alichry/laminas-accesscontrol/blob/master/src/Identity/IdentityInterface.php). The methods to implement are `hasPermission` and `hasRole`, in an ORM environment where the associations are already defined, it is easy to implement such methods.
- The authorization service requires an authentication service, configure [`Doctrine\Authentication`](https://github.com/doctrine/DoctrineModule/blob/master/docs/authentication.md)to quickly deploy an authentication service based on your identity type.
- Configure this module by defining a "global" authorization link:

```
