From 82668938af3e3b5b38faaadb72e664f1497984ee Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Wed, 19 Mar 2025 11:56:02 +0100 Subject: [PATCH] Use 'permanent' session with a timeout --- README.md | 5 ++++- staticshield.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9e10791..69c969c 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,12 @@ After=network.target [Service] User=divault WorkingDirectory=/srv/staticshield -Environment=FLASK_SERVE_DIR="/srv/a_static_website/html" +#StandardOutput=file:/srv/logs/staticshield.log +Environment=FLASK_SERVE_DIR="/srv/some_static_website/html" Environment=FLASK_MOTHERSHIP="https://api.example.com/api/staticshield" Environment=FLASK_SESSION_COOKIE_NAME="staticshield" +# Max session length of 2h +Environment=FLASK_PERMANENT_SESSION_LIFETIME=7200 ExecStart=/application/venvs/staticshield/bin/gunicorn -b localhost:8000 -w 4 staticshield:app #ExecStart=/application/venvs/staticshield/bin/gunicorn -b unix:staticshield.sock -m 007 -w 4 staticshield:app Restart=always diff --git a/staticshield.py b/staticshield.py index 7015092..f01ab60 100644 --- a/staticshield.py +++ b/staticshield.py @@ -26,7 +26,7 @@ dictConfig({ app = Flask(__name__) app.config.from_prefixed_env() -app.config['SESSION_PERMANENT'] = False +app.config['SESSION_PERMANENT'] = True app.config['SESSION_TYPE'] = 'filesystem' Session(app)