dflydev / stack-basic-authentication
HTTP基本认证中间件
dev-master / 1.0.x-dev
2014-12-08 22:04 UTC
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-08-29 03:31:22 UTC
README
A Stack middleware to enable HTTP Basic Authentication following the STACK-2 Authentication conventions.
安装
通过 Composer 作为 dflydev/stack-basic-authentication 安装。
用法
BasicAuthentication中间件接受以下选项
- authenticator: (必需) 用于确保指定凭证正确的回调函数。
- realm: 根据 RFC1945 定义的HTTP基本认证领域。
- firewall: 与 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/
目录中此中间件的一些实际使用示例。
许可证
MIT, 查看 LICENSE。
社区
如果您有问题或想提供帮助,请加入我们 irc.freenode.net 上的 #stackphp 或 #dflydev 频道。