에만 특정 경로에 대해 실행되는, HttpBasicAuth에 따라 사용자 정의 미들웨어를 작성하여이를 수행 할 수 있습니다 http://help.slimframework.com/discussions/questions/296-middleware-usage-only-on-specific-routes
에
class HttpBasicAuthCustom extends \Slim\Extras\Middleware\HttpBasicAuth {
protected $route;
public function __construct($username, $password, $realm = 'Protected Area', $route = '') {
$this->route = $route;
parent::__construct($username, $password, $realm);
}
public function call() {
if(strpos($this->app->request()->getPathInfo(), $this->route) !== false) {
parent::call();
return;
}
$this->next->call();
}
}
$app->add(new HttpBasicAuthCustom('username', 'password', 'Some Realm Name', 'someroute'));
$app->get('/someroute', function() use ($app) {
echo "Welcome!";
})->name('someroute');
감사합니다