Skip to content

mmiroslav/slim-basic-auth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Basic Auth Middleware for Slim

This middleware implements HTTP Basic Authentication for Slim Framework.

Install

You can install the middleware using composer.

{
    "require": {
        "mmiroslav/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. In responseContent place text for response body.

$app = new \Slim\Slim();

$app->add(new \Slim\Middleware\HttpBasicAuth(array(
    "path" => "/admin",
    "realm" => "Protected",
    "responseContent" => " 401 Unauthorized",
    "users" => array(
        "root" => "t00r",
        "user" => "passw0rd"
    )
)));

About

HTTP Basic Authentication for Slim Framework

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%