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:
@@ -11,7 +11,7 @@ from flask_wtf.csrf import CSRFError, CSRFProtect
|
||||
from markupsafe import Markup, escape
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
||||
from config import Config
|
||||
from config import Config, guard_default_secret_key
|
||||
|
||||
# **bold**, the whole of the markup a task description understands besides the
|
||||
# line break. DOTALL so a phrase that wraps onto the next line still closes.
|
||||
@@ -80,6 +80,11 @@ def create_app() -> Flask:
|
||||
app.register_blueprint(statistics_bp, url_prefix="/statistics")
|
||||
app.register_blueprint(admin_bp, url_prefix="/admin")
|
||||
|
||||
@app.before_request
|
||||
def _check_secret_key():
|
||||
"""See guard_default_secret_key in config.py (#33)."""
|
||||
guard_default_secret_key(app)
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
"""Root redirect to login or dashboard based on session."""
|
||||
|
||||
Reference in New Issue
Block a user