denault / slim-basic-auth
HTTP Basic Authentication Middleware for Slim Framework
Installs: 248
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 65
pkg:composer/denault/slim-basic-auth
Requires
- php: >=5.3.0
- slim/slim: >=2.3.0
This package is not auto-updated.
Last update: 2025-10-21 07:30:26 UTC
README
Forked from: https://travis-ci.org/tuupola/slim-basic-auth
This middleware implements HTTP Basic Authentication for Slim Framework.
Install
You can install the middleware using composer.
{ "require": { "tuupola/slim-basic-auth": "dev-master", } }
Usage
Configuration options are passed as an array. Only mandatory parameter is users. This is an array where you pass one or more "username" => "password" combinations. Username is the key and password is the value.
$app = new \Slim\Slim(); $app->add(new \Slim\Middleware\HttpBasicAuth(array( "users" => array( "root" => "t00r", "user" => "passw0rd" ) )));
With optional path parameter can authenticate only given part of your website. You can also change the displayed realm using the parameter with same name.
$app = new \Slim\Slim(); $app->add(new \Slim\Middleware\HttpBasicAuth(array( "path" => "/admin", "realm" => "Protected", "users" => array( "root" => "t00r", "user" => "passw0rd" ) )));