julionc/slim-basic-auth-middleware

该包已 弃用 并不再维护。没有建议替代包。

Slim 框架的 HTTP Basic 认证中间件

3.0.0 2016-04-28 00:54 UTC

This package is not auto-updated.

Last update: 2023-09-16 10:07:29 UTC


README

Slim 框架的 HTTP Basic 认证中间件。

Build Status

该仓库包含一个 Slim 框架 HTTP Basic Auth 服务提供者。这使您能够定义规则,根据设置的用户名和密码提供基本的用户认证。同时,设置 Realm 和 Router 名称。

安装

通过 Composer

$ composer require julionc/slim-basic-auth-middleware

需要 Slim 3.0.0 或更高版本。

用法

$app = new \Slim\App();

// Fetch DI Container
$container = $app->getContainer();

$basic_auth = new \Slim\HttpBasicAuth\Rule('admin', 'admin', null, '/admin');

// Register provider
$container->register($basic_auth);

$app->get('/admin', function ($req, $res, $args) {
    // Show dashboard
});

$app->get('/foo', function ($req, $res, $args) {
    // Show custom page
})->add($basic_auth);

$app->run();

测试

$ phpunit

贡献

请参阅 CONTRIBUTING 了解详细信息。

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 以获取更多信息。