feat(sécurité): Implémente le verrouillage de l'intranet avec une page d'erreur personnalisée.

This commit is contained in:
Serreau Jovann
2026-01-19 08:38:10 +01:00
parent 52eecfda03
commit 1afc6a20ea
6 changed files with 108 additions and 0 deletions

1
.env
View File

@@ -96,3 +96,4 @@ ESY_SEARCH_KEY=b09d9a708b427d495c39fe6e8fc5361fe33fee57a0435f3e1bf3ed8155f2a277
###> stripe/stripe-php ###
STRIPE_SECRET_KEY=sk_test_***
###< stripe/stripe-php ###
INTRANET_LOCK=true

2
assets/error.js Normal file
View File

@@ -0,0 +1,2 @@
import './error.scss'
console.log("loaded")

1
assets/error.scss Normal file
View File

@@ -0,0 +1 @@
@import "tailwindcss";

View File

@@ -0,0 +1,29 @@
<?php
namespace App\Security;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Twig\Environment;
#[AsEventListener(RequestEvent::class,method: 'onLocked')]
class IntranetLocked
{
public function __construct(private readonly Environment $environment)
{
}
public function onLocked(RequestEvent $requestEvent)
{
if($_ENV['INTRANET_LOCK'] == "true" &&
!str_contains( $requestEvent->getRequest()->getPathInfo(),"_wdt") &&
!str_contains( $requestEvent->getRequest()->getPathInfo(),"_profiler")
) {
$response = new Response($this->environment->render('security/locked.twig'));
$response->setStatusCode(Response::HTTP_FORBIDDEN);
$requestEvent->setResponse($response);
}
}
}

View File

@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Accès Restreint - Siteconseil</title>
{{ vite_asset('error.js') }}
</head>
<body class="bg-[#0f172a] text-slate-200 font-sans min-h-screen flex items-center justify-center overflow-hidden">
<div class="absolute inset-0 overflow-hidden pointer-events-none">
<div class="absolute -top-[10%] -left-[10%] w-[50%] h-[50%] bg-blue-600/10 rounded-full blur-[120px]"></div>
<div class="absolute -bottom-[10%] -right-[10%] w-[50%] h-[50%] bg-indigo-600/10 rounded-full blur-[120px]"></div>
</div>
<div class="relative z-10 w-full max-w-lg p-6 mx-auto">
<div class="backdrop-blur-3xl bg-slate-900/60 border border-white/10 rounded-[3rem] p-10 shadow-2xl">
<div class="flex justify-center mb-8">
<div class="p-6 bg-amber-500/10 rounded-3xl border border-amber-500/20">
<svg class="w-12 h-12 text-amber-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
</svg>
</div>
</div>
<div class="text-center mb-10">
<h1 class="text-3xl font-black text-white mb-4 tracking-tight uppercase">
Accès <span class="text-blue-500">Restreint</span>
</h1>
<p class="text-slate-400 text-sm leading-relaxed">
L'accès à votre espace intranet est actuellement restreint.
Pour obtenir plus d'informations, veuillez contacter notre service client.
</p>
</div>
<div class="bg-white/5 border border-white/5 rounded-2xl p-6 mb-8 space-y-4">
<p class="text-[10px] text-blue-400 font-black uppercase tracking-[0.2em] text-center mb-2">Service Client Siteconseil</p>
<a href="mailto:s.com@siteconseil.fr" class="flex items-center space-x-4 p-3 rounded-xl hover:bg-white/5 transition-colors group">
<div class="w-10 h-10 rounded-lg bg-blue-600/20 flex items-center justify-center text-blue-500 group-hover:bg-blue-600 group-hover:text-white transition-all">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
</div>
<div>
<p class="text-[9px] text-slate-500 font-bold uppercase tracking-wider">Email</p>
<p class="text-sm font-semibold text-white">s.com@siteconseil.fr</p>
</div>
</a>
<a href="tel:0323056243" class="flex items-center space-x-4 p-3 rounded-xl hover:bg-white/5 transition-colors group">
<div class="w-10 h-10 rounded-lg bg-green-600/20 flex items-center justify-center text-green-500 group-hover:bg-green-600 group-hover:text-white transition-all">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>
</svg>
</div>
<div>
<p class="text-[9px] text-slate-500 font-bold uppercase tracking-wider">Téléphone</p>
<p class="text-sm font-semibold text-white">03 23 05 62 43</p>
</div>
</a>
</div>
<div class="text-center">
<p class="text-[9px] text-slate-600 uppercase tracking-[0.3em] font-black italic">
Siteconseil &copy; 2026
</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -43,6 +43,7 @@ export default defineConfig({
input: {
app: resolve(__dirname, 'assets/app.js'),
admin: resolve(__dirname, 'assets/admin.js'),
error: resolve(__dirname, 'assets/error.js'),
}
},
},