dflydev / stack-basic-authentication
HTTP Basic Authentication Stack middleware
Installs: 3 754
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 4
Forks: 3
Open Issues: 2
Requires
- php: >=5.4.0
- dflydev/stack-authentication: 1.0.*@dev
- dflydev/stack-firewall: 1.0.*@dev
- pimple/pimple: 1.*
- symfony/http-foundation: ~2.1
- symfony/http-kernel: ~2.1
Requires (Dev)
- phpunit/phpunit: 3.7.21
- silex/silex: 1.1.*@dev
- stack/builder: ~1.0@dev
- stack/callable-http-kernel: ~1.0@dev
- stack/inline: ~1.0@dev
- symfony/browser-kit: ~2.1
This package is auto-updated.
Last update: 2024-11-29 03:58:12 UTC
README
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.