2017 © Pedro Peláez
 

library slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

image

chadicus/slim-oauth2-middleware

OAuth2 middleware for use within a Slim Framework API

  • Monday, May 21, 2018
  • by chadicus
  • Repository
  • 4 Watchers
  • 38 Stars
  • 41,940 Installations
  • PHP
  • 1 Dependents
  • 2 Suggesters
  • 14 Forks
  • 1 Open issues
  • 23 Versions
  • 17 % Grown

The README.md

Chadicus\Slim\OAuth2\Middleware

Latest Stable Version Latest Unstable Version License, (*1)

Total Downloads Daily Downloads Monthly Downloads, (*2)

Documentation, (*3)

Middleware for using OAuth2 Server within a Slim 3 Framework API, (*4)

Requirements

Chadicus\Slim\OAuth2\Middleware requires PHP 5.6 (or later)., (*5)

Composer

To add the library as a local, per-project dependency use Composer! Simply add a dependency on chadicus/slim-oauth2-middleware to your project's composer.json file such as:, (*6)

composer require chadicus/slim-oauth2-middleware

Contact

Developers may be contacted at:, (*7)

Project Build

With a checkout of the code get Composer in your PATH and run:, (*8)

composer install
./vendor/bin/phpunit
./vendor/bin/phpcs

Community

Gitter, (*9)

Example Usage

Simple example for using the authorization middleware., (*10)

use Chadicus\Slim\OAuth2\Middleware;
use OAuth2;
use OAuth2\Storage;
use OAuth2\GrantType;
use Slim;

//set up storage for oauth2 server
$storage = new Storage\Memory(
    [
        'client_credentials' => [
            'administrator' => [
                'client_id' => 'administrator',
                'client_secret' => 'password',
                'scope' => 'superUser',
            ],
            'foo-client' => [
                'client_id' => 'foo-client',
                'client_secret' => 'p4ssw0rd',
                'scope' => 'basicUser canViewFoos',
            ],
            'bar-client' => [
                'client_id' => 'foo-client',
                'client_secret' => '!password1',
                'scope' => 'basicUser',
            ],
        ],
    ]
);

// create the oauth2 server
$server = new OAuth2\Server(
    $storage,
    [
        'access_lifetime' => 3600,
    ],
    [
        new GrantType\ClientCredentials($storage),
    ]
);

//create the basic app
$app = new Slim\App();

// create the authorization middlware
$authMiddleware = new Middleware\Authorization($server, $app->getContainer());

//Assumes token endpoints available for creating access tokens

$app->get('foos', function ($request, $response, $args) {
    //return all foos, no scope required
})->add($authMiddleware);

$getRouteCallback = function ($request, $response, $id) {
    //return details for a foo, requires superUser scope OR basicUser with canViewFoos scope
};

$app->get('foos/id', $getRouteCallback)->add($authMiddleware->withRequiredScope(['superUser', ['basicUser', 'canViewFoos']]));

$postRouteCallback = function ($request, $response, $args) {
    //Create a new foo, requires superUser scope
};

$app->post('foos', $postRouteCallback)->add($authMiddleware->withRequiredScope(['superUser']));

$app->run();

The Versions

21/05 2018
18/05 2018
29/09 2016

dev-dev/update-dependencies

dev-dev/update-dependencies

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

23/05 2016

v3.0.1

3.0.1.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

22/05 2016

v3.0.0

3.0.0.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

04/02 2016

v1.x-dev

1.9999999.9999999.9999999-dev

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

04/02 2016

v1.0.0

1.0.0.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

12/10 2015

v0.2.3

0.2.3.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

23/09 2015

v0.2.2

0.2.2.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

09/09 2015

v0.2.1

0.2.1.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

28/07 2015

v0.2.0

0.2.0.0

OAuth2 middleware for use within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

24/07 2015

v0.1.1

0.1.1.0

Middleware for Using OAuth2 within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim

23/07 2015

v0.1.0

0.1.0.0

Middleware for Using OAuth2 within a Slim Framework API

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware oauth2 slim