feat(api): Ajoute l'authentification et corrige le type de contenu pour les serveurs.

This commit is contained in:
Serreau Jovann
2025-11-05 18:41:24 +01:00
parent d88b8268ce
commit 6225d03502
3 changed files with 4 additions and 3 deletions

View File

@@ -14,6 +14,6 @@ class ServersController extends AbstractController
{
return new Response($this->renderView('api/private/infra/servers.twig', [
'servers' => $computeRepository->findAll(),
]),200);
]),200,['Content-Type' => 'text/plain']);
}
}

View File

@@ -32,6 +32,7 @@ class ApiSubscriber
public function onKernelRequest(RequestEvent $event): void
{
$request = $event->getRequest();
$request->headers->set('EsyWebKey',$_ENV['APP_SECRET']);
$pathInfo = $request->getPathInfo();
if (str_contains($pathInfo, '/api/private')) {
if(!$request->headers->has('EsyWebKey')) {

View File

@@ -1,4 +1,4 @@
[servers]<br/>
[servers]
{% for server in servers %}
{{ server.externalIp}} ansible_connection=local ansible_python_interpreter=/usr/bin/python3 path=/var/www/watchdog<br/>
{{ server.externalIp}} ansible_connection=local ansible_python_interpreter=/usr/bin/python3 path=/var/www/watchdog
{% endfor %}