Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

HTTP Basic Authentication Stack Middleware

A Stack middleware to enable HTTP Basic Authentication following the STACK-2 Authentication conventions.

Installation

Through Composer as dflydev/stack-basic-authentication.

Usage

The BasicAuthentication middleware accepts the following options:

  • authenticator: (required) A callback used to ensure that the specified credentials are correct.
  • realm: The HTTP Basic Authentication realm as defined by RFC1945.
  • firewall: A firewall configuration compatible with dflydev/stack-firewall.
<?php

$authenticator = function ($username, $password) {
    // Given a username and password credentials, ensure that
    // the credentials are correct and return a token that
    // represents the user for this request.
    if ('admin' === $username && 'default' === $password) {
        return 'admin-user-token';
    }
};

$app = new Dflydev\Stack\BasicAuthentication($app, [
    'firewall' => [
        ['path' => '/', 'anonymous' => true],
        ['path' => '/login'],
    ],
    'authenticator' => $authenticator,
    'realm' => 'here there be dragons',
]);

Examples

See the examples/ directory for some live examples of this middleware in action.

License

MIT, see LICENSE.

Community

If you have questions or want to help out, join us in the #stackphp or #dflydev channels on irc.freenode.net.

About

HTTP Basic Authentication Stack middleware

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.