julionc/slim-basic-auth-middleware

This package is abandoned and no longer maintained. No replacement package was suggested.

HTTP Basic Authentication Middleware for Slim Framework

3.0.0 2016-04-28 00:54 UTC

This package is not auto-updated.

Last update: 2023-09-16 10:07:29 UTC


README

HTTP Basic Authentication Middleware for Slim Framework.

Build Status

This repository contains a Slim Framework HTTP Basic Auth service provider. This enables you to define Rules that will provide you with basic user authentication based on username and password set. Also, Realm and Router name set.

Install

Via Composer

$ composer require julionc/slim-basic-auth-middleware

Requires Slim 3.0.0 or newer.

Usage

$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

$basic_auth = new \Slim\HttpBasicAuth\Rule('admin', 'admin', null, '/admin');

// Register provider
$container->register($basic_auth);

$app->get('/admin', function ($req, $res, $args) {
    // Show dashboard
});

$app->get('/foo', function ($req, $res, $args) {
    // Show custom page
})->add($basic_auth);

$app->run();

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.