Bezbednost — security headers, fail2ban logovanje, bruteforce zaštita, CSRF zaštita
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
params.append('naziv', this.modalNaziv.trim());
|
||||
if (this.modalKategorijaID) params.append('kategorija_id', this.modalKategorijaID);
|
||||
if (this.modalCena) params.append('prodajna_cena', this.modalCena);
|
||||
params.append('_csrf', document.querySelector('meta[name="csrf-token"]')?.content || '');
|
||||
|
||||
try {
|
||||
const odgovor = await fetch('/magacin/novi', {
|
||||
|
||||
@@ -110,6 +110,11 @@
|
||||
<div class="greska">Pogrešno korisničko ime ili lozinka.</div>
|
||||
{{else if eq .Greska "2"}}
|
||||
<div class="greska">Greška na serveru. Pokušajte ponovo.</div>
|
||||
{{else if eq .Greska "zakljucano"}}
|
||||
<div class="greska">
|
||||
Previše neuspelih pokušaja prijave. IP adresa je privremeno blokirana.
|
||||
{{if .Preostalo}}<br>Pokušajte ponovo za: <strong>{{.Preostalo}}</strong>{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .Sacuvano}}
|
||||
@@ -117,6 +122,7 @@
|
||||
{{end}}
|
||||
|
||||
<form method="POST" action="/prijava">
|
||||
<input type="hidden" name="_csrf" value="{{.CsrfToken}}">
|
||||
<div class="polje">
|
||||
<label for="korisnicko_ime">Korisničko ime</label>
|
||||
<input type="text" id="korisnicko_ime" name="korisnicko_ime"
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
{{end}}
|
||||
|
||||
<form method="POST" action="/setup">
|
||||
<input type="hidden" name="_csrf" value="{{.CsrfToken}}">
|
||||
<div class="polje">
|
||||
<label for="korisnicko_ime">Korisničko ime</label>
|
||||
<input type="text" id="korisnicko_ime" name="korisnicko_ime"
|
||||
|
||||
@@ -91,6 +91,7 @@
|
||||
{{end}}
|
||||
|
||||
<form method="POST" action="/prijava/totp">
|
||||
<input type="hidden" name="_csrf" value="{{.CsrfToken}}">
|
||||
<div class="polje">
|
||||
<label for="kod">Kod za verifikaciju</label>
|
||||
<input type="text" id="kod" name="kod"
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{block "naslov" .}}NTech{{end}}</title>
|
||||
<meta name="csrf-token" content="{{.CsrfToken}}">
|
||||
|
||||
<!-- tema — učitava se prva -->
|
||||
<link rel="stylesheet" href="/static/css/teme/{{.Tema}}.css" />
|
||||
@@ -82,6 +83,20 @@
|
||||
</script>
|
||||
|
||||
{{block "dodatni-js" .}}{{end}}
|
||||
|
||||
<!-- CSRF: automatski dodaje skriveno polje u sve POST forme -->
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var m = document.querySelector('meta[name="csrf-token"]');
|
||||
if (!m || !m.content) return;
|
||||
document.querySelectorAll('form[method="POST"],form[method="post"]').forEach(function(f) {
|
||||
if (f.querySelector('input[name="_csrf"]')) return;
|
||||
var i = document.createElement('input');
|
||||
i.type = 'hidden'; i.name = '_csrf'; i.value = m.content;
|
||||
f.appendChild(i);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user