2017 © Pedro Peláez
 

library slim-middleware-basic-acl

PSR-7 HTTP Authentication Access Middleware

image

rcs_us/slim-middleware-basic-acl

PSR-7 HTTP Authentication Access Middleware

  • Sunday, January 7, 2018
  • by conrad10781
  • Repository
  • 1 Watchers
  • 1 Stars
  • 177 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 40 % Grown

The README.md

PSR-7 HTTP Authentication ACL Middleware

This middleware provides a very simple way to implement ACL in a PSR-7 environment., (*1)

It has been tested with Slim Framework using the [PSR-7 Basic Auth Middleware] provided by tuupola (https://github.com/tuupola/slim-basic-auth)., (*2)

Install

Install latest version using composer., (*3)

$ composer require rcs_us/slim-middleware-basic-acl

Usage

The middleware accepts two possible parameters., (*4)

  1. An array of one or more usernames allowed to access the route. This compares against the value that is ultimately stored in $_SERVER["PHP_AUTH_USER"] | $request->getServerParams()["PHP_AUTH_USER"] .
  2. A callable that can do more complicated comparisons on $_SERVER["PHP_AUTH_USER"] | $request->getServerParams()["PHP_AUTH_USER"] .
$app = new \Slim\App;
// .... implement HTTP Authentication , IE $app->add(new \Slim\Middleware\HttpBasicAuthentication( ... 

// array of usernames
$app->get("/path/of/your/route", "\App\Controller\SomeController:methodToCall")->add(new \Slim\Middleware\HttpBasicACL(["username1", "username2"]));

// callable
$app->get("/path/of/your/route", "\App\Controller\SomeController:methodToCall")->add(new \Slim\Middleware\HttpBasicACL(function ($request, $response) {
    // Some Logic Here Based On $_SERVER["PHP_AUTH_USER"] | $request->getServerParams()["PHP_AUTH_USER"] .
    // Returning false will trigger a 403, true will execute route
    return false;
}));

The Versions

07/01 2018

dev-master

9999999-dev

PSR-7 HTTP Authentication Access Middleware

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

middleware psr-7 acl

07/01 2018

1.0.0

1.0.0.0

PSR-7 HTTP Authentication Access Middleware

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

middleware psr-7 acl