aist / authorization-middleware
PSR-7 Authorization Middleware
dev-master
2017-08-09 02:18 UTC
Requires
- php: ^7.0
- container-interop/container-interop: ^1.2
- http-interop/http-middleware: ^0.4.1
- psr/http-message: ^1.0
- zendframework/zend-authentication: ^2.5
- zendframework/zend-expressive-router: ^2.1
- zendframework/zend-expressive-template: ^1.0
- zendframework/zend-session: ^2.8
Requires (Dev)
- malukenho/docheader: ^0.1.5
- mmoreram/php-formatter: ^1.3
- phpunit/phpunit: ^6.0.7 || ^5.7.14
- satooshi/php-coveralls: ^1.0
- zendframework/zend-coding-standard: ~1.0.0
- zendframework/zend-diactoros: ^1.1
This package is not auto-updated.
Last update: 2024-11-10 03:36:12 UTC
README
PSR-7 Authorization Middleware.
Installation
Install via composer:
$ composer require aist/authorization-middleware
Configuration
Add pipe to protect whole app
// Add more middleware here that needs to introspect the routing results; this
// might include:
//
// - route-based authentication
// - route-based validation
// - etc.
// Authentication middleware
$app->pipe(\Aist\AuthenticationMiddleware\Middleware\AuthenticationMiddleware::class);
// Authorization middleware
// At this point, if no identity is set by authorization middleware, the
// UnauthorizedHandler kicks in; alternately, you can provide other fallback
// middleware to execute.
//$app->pipe(\Aist\AuthorizationMiddleware\Middleware\UnauthorizedHandler::class);
// Authorization
$app->pipe(\Aist\AuthorizationMiddleware\Middleware\AuthorizationMiddleware::class);
or use for specific route
$app->get(
'/',
[
\Aist\AuthenticationMiddleware\Middleware\AuthenticationMiddleware::class,
\Aist\AuthorizationMiddleware\Middleware\AuthorizationMiddleware::class,
App\Action\DashboardAction::class,
],
'dashboard'
);