fix(auth): SECRET_KEY di default rifiutato, session.permanent, logout solo POST (#33)
config.py: guard_default_secret_key, verificata a ogni richiesta (prima di create_app, TESTING/DEBUG non sono ancora impostati dai fixture di test) — rifiuta con RuntimeError se CLIENT_SECRET_KEY è rimasto al default committato fuori da debug/testing. auth.py: session.permanent=True al login (senza, PERMANENT_SESSION_LIFETIME non aveva mai effetto); /auth/logout solo POST, con CSRF. Aggiornati i tre punti che lo chiamavano: profile.html e navbar.html (link -> form POST), auto-logout JS in base.html (fetch POST + redirect al login). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -151,7 +151,17 @@
|
||||
var remaining = timeoutMs - elapsed;
|
||||
if (remaining <= 0) {
|
||||
clearInterval(this._interval);
|
||||
window.location.href = '{{ url_for("auth.logout") }}';
|
||||
// #33: /auth/logout is POST-only now (CSRF-protected), so a plain
|
||||
// navigation would 405. Fire the logout, then leave regardless of
|
||||
// the outcome - staying logged in client-side is worse than a
|
||||
// logout call that failed silently.
|
||||
var csrfMeta = document.querySelector('meta[name=csrf-token]');
|
||||
fetch('{{ url_for("auth.logout") }}', {
|
||||
method: 'POST',
|
||||
headers: csrfMeta ? { 'X-CSRFToken': csrfMeta.content } : {}
|
||||
}).finally(function() {
|
||||
window.location.href = '{{ url_for("auth.login") }}';
|
||||
});
|
||||
} else if (remaining <= warningMs) {
|
||||
this.showWarning = true;
|
||||
this.remainingSeconds = Math.ceil(remaining / 1000);
|
||||
|
||||
Reference in New Issue
Block a user