itinance / slim-basic-auth-pass-through
在slim-basic-auth基础上扩展,基本将任何认证数据传递到请求中
1.1.3
2019-04-05 07:24 UTC
Requires
- php: ^7.1
- slim/slim: ^3.12
- tuupola/slim-basic-auth: ^3.2
This package is not auto-updated.
Last update: 2024-09-15 09:06:12 UTC
README
HttpBasicAuthentication的装饰器,将任何带有密码的用户传递并通过,使其可用于控制器(例如,用于代理-API的重用)。
它基于HttpBasicAuthentication。除了HttpBasicAuthentication构造函数接受的参数外,还可以将其他参数传递给PassThroughHttpBasicAuthentication。
示例
use itinance\Middleware\PassThroughHttpBasicAuthentication
$app = new \Slim\App($config);
$app->add(new PassThroughHttpBasicAuthentication([
"realm" => "Protected",
]));
// Define app routes
$app->post('/soapProxy/{methodName}', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) {
$user = $params['PHP_AUTH_USER'];
$pass = $params['PHP_AUTH_PW'];
// Proxy-Call to another API with Username and Password happens here
// ...proxyCall($user, $pass, ...)
});
// Run app
$app->run();