security(headers): ajoute les en-têtes HTTP de sécurité et refactorise les scripts inline pour CSP

- Ajoute .htaccess avec HSTS, CSP, X-Frame-Options, X-Content-Type-Options,
  Referrer-Policy et Permissions-Policy
- Déplace les scripts inline (thème, redirection de langue) vers des fichiers JS externes
- Remplace les onclick inline par des écouteurs d'événements dans main.js
- Configure Eleventy pour copier .htaccess à la racine du site
This commit is contained in:
2026-07-07 23:56:56 +04:00
parent 8dac00d692
commit 36d1e307bd
9 changed files with 89 additions and 43 deletions
+3 -38
View File
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="{{ locale }}">
<html lang="{{ locale }}" data-locale="{{ locale }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -100,43 +100,8 @@
}
</script>
<script>
(function() {
// Récupérer le thème stocké ou détecter le thème système
const storedTheme = localStorage.getItem('oki-theme');
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
let theme = storedTheme;
// Si pas de préférence stockée, utiliser le thème système
if (!storedTheme) {
theme = systemPrefersDark ? 'dark' : 'light';
}
// Appliquer le thème immédiatement
if (theme === 'light') {
document.documentElement.classList.add('light-theme');
}
})();
</script>
<script>
(function() {
// Redirection automatique selon la langue du navigateur, sauf choix explicite déjà mémorisé
var pref = localStorage.getItem('oki-lang-pref');
if (pref) return;
var browserLang = (navigator.language || navigator.userLanguage || '').toLowerCase();
var wantsEnglish = browserLang.indexOf('en') === 0;
var currentLocale = '{{ locale }}';
if (wantsEnglish && currentLocale !== 'en') {
window.location.replace('/en/' + window.location.hash);
} else if (!wantsEnglish && currentLocale === 'en') {
window.location.replace('/' + window.location.hash);
}
})();
</script>
<script src="/assets/js/theme.js"></script>
<script src="/assets/js/lang-redirect.js"></script>
</head>
<body>
{% include "partials/nav.njk" %}
+1 -1
View File
@@ -8,7 +8,7 @@
<div class="faq-container">
{% for item in t.faq.items %}
<div class="faq-item">
<button class="faq-question" onclick="this.parentElement.classList.toggle('active')">
<button class="faq-question">
<span>{{ item.question }}</span>
<span class="faq-icon">+</span>
</button>
+2 -2
View File
@@ -31,9 +31,9 @@
{% endfor %}
</ul>
{% if locale == 'en' %}
<a href="#" class="lang-switch" onclick="localStorage.setItem('oki-lang-pref','fr'); switchLanguage('fr'); return false;">{{ t.ui.lang_switch_label }}</a>
<a href="#" class="lang-switch" data-lang="fr">{{ t.ui.lang_switch_label }}</a>
{% else %}
<a href="#" class="lang-switch" onclick="localStorage.setItem('oki-lang-pref','en'); switchLanguage('en'); return false;">{{ t.ui.lang_switch_label }}</a>
<a href="#" class="lang-switch" data-lang="en">{{ t.ui.lang_switch_label }}</a>
{% endif %}
<button id="theme-toggle" class="theme-toggle" aria-label="{{ t.ui.theme_toggle }}" title="{{ t.ui.theme_toggle }}">
<span class="theme-icon theme-icon-dark">🌙</span>
+2 -2
View File
@@ -26,7 +26,7 @@
<div class="custom-donation-form">
<input type="number" id="customAmountOneTime" placeholder="{{ t.support.custom_amount_placeholder }}" min="1" class="custom-amount-input">
<span class="currency-symbol">{{ t.support.one_time_suffix }}</span>
<button onclick="handleCustomDonation('oneTime')" class="custom-donation-btn custom-donation-btn-primary">
<button data-donation-type="oneTime" class="custom-donation-btn custom-donation-btn-primary">
{{ t.support.custom_amount_btn }}
</button>
</div>
@@ -49,7 +49,7 @@
<div class="custom-donation-form">
<input type="number" id="customAmountMonthly" placeholder="{{ t.support.custom_amount_placeholder }}" min="1" class="custom-amount-input custom-amount-input-monthly">
<span class="currency-symbol">{{ t.support.monthly_suffix }}</span>
<button onclick="handleCustomDonation('monthly')" class="custom-donation-btn custom-donation-btn-secondary">
<button data-donation-type="monthly" class="custom-donation-btn custom-donation-btn-secondary">
{{ t.support.custom_monthly_btn }}
</button>
</div>