Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

julionc/slim-basic-auth-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slim Framework HTTP Basic Auth

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.