diff --git a/.env b/.env index 39bd369..781f8e4 100644 --- a/.env +++ b/.env @@ -15,3 +15,9 @@ RUN_MODE = "PRODU" #PRODU | DEVEL #Configuring the parameter CHECK_PHP_TASKS_SYNTAX to false in case of syntax errors in the tasks could cause anomalous behavior in the Crunz-ui interfaces CHECK_PHP_TASKS_SYNTAX = true #true | false + +#TOOLS BASIC AUTH CONFIGURATION +TOOLS_LOGIN = "tools_user" +TOOLS_PASSWORD = "tools_password" + +#Please, update tools user grant as soon as possible diff --git a/routes/api/tools.php b/routes/api/tools.php new file mode 100644 index 0000000..ce828b9 --- /dev/null +++ b/routes/api/tools.php @@ -0,0 +1,33 @@ +group('/tools', function (RouteCollectorProxy $group) { + + $group->get('/test-conn', function (Request $request, Response $response, array $args) { + + $data = []; + + + $response->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); + return $response->withStatus(200) + ->withHeader("Content-Type", "application/json"); + }); + +}); diff --git a/routes/index.php b/routes/index.php index db79f87..13c337c 100644 --- a/routes/index.php +++ b/routes/index.php @@ -67,7 +67,24 @@ "secure" => false, "secret" => $_ENV["JWT_SECRET"], - "ignore" => [$base_path."/auth/login", $base_path."/test"], + "ignore" => [$base_path."/auth/login", $base_path."/tools" ], + + "error" => function ($response, $arguments) { + $data = []; + $data["status"] = "Authentication error"; + $data["message"] = $arguments["message"]; + + $response->getBody()->write(json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); + return $response->withHeader("Content-Type", "application/json"); + } +])); + +$app->add(new Tuupola\Middleware\HttpBasicAuthentication([ + "path" => [ $base_path."/tools" ], + "realm" => "Protected", + "users" => [ + $_ENV["TOOLS_LOGIN"] => $_ENV["TOOLS_PASSWORD"] + ], "error" => function ($response, $arguments) { $data = [];