From 7f867309097cf477e0bc0d73f5613b8a39371bc2 Mon Sep 17 00:00:00 2001 From: jodygilbert <74103313+jodygilbert@users.noreply.github.com> Date: Sun, 24 Jan 2021 08:09:53 +0000 Subject: [PATCH] allow-server-side-sessions (#855) --- configs/docker_config.py | 6 ++++-- powerdnsadmin/__init__.py | 7 +++++++ powerdnsadmin/default_config.py | 1 + requirements.txt | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configs/docker_config.py b/configs/docker_config.py index e2bbc62..1723556 100644 --- a/configs/docker_config.py +++ b/configs/docker_config.py @@ -47,7 +47,8 @@ legal_envvars = ( 'SAML_ASSERTION_ENCRYPTED', 'OFFLINE_MODE', 'REMOTE_USER_LOGOUT_URL', - 'REMOTE_USER_COOKIES' + 'REMOTE_USER_COOKIES', + 'FILESYSTEM_SESSIONS_ENABLED' ) legal_envvars_int = ('PORT', 'MAIL_PORT', 'SAML_METADATA_CACHE_LIFETIME') @@ -65,7 +66,8 @@ legal_envvars_bool = ( 'SAML_LOGOUT', 'SAML_ASSERTION_ENCRYPTED', 'OFFLINE_MODE', - 'REMOTE_USER_ENABLED' + 'REMOTE_USER_ENABLED', + 'FILESYSTEM_SESSIONS_ENABLED' ) # import everything from environment variables diff --git a/powerdnsadmin/__init__.py b/powerdnsadmin/__init__.py index e6ac703..a8270b0 100755 --- a/powerdnsadmin/__init__.py +++ b/powerdnsadmin/__init__.py @@ -4,6 +4,7 @@ from flask import Flask from flask_seasurf import SeaSurf from flask_mail import Mail from werkzeug.middleware.proxy_fix import ProxyFix +from flask_session import Session from .lib import utils @@ -78,6 +79,12 @@ def create_app(config=None): from flask_sslify import SSLify _sslify = SSLify(app) # lgtm [py/unused-local-variable] + # Load Flask-Session + if app.config.get('FILESYSTEM_SESSIONS_ENABLED'): + app.config['SESSION_TYPE'] = 'filesystem' + sess = Session() + sess.init_app(app) + # SMTP app.mail = Mail(app) diff --git a/powerdnsadmin/default_config.py b/powerdnsadmin/default_config.py index ce09bcc..42b26b4 100644 --- a/powerdnsadmin/default_config.py +++ b/powerdnsadmin/default_config.py @@ -8,6 +8,7 @@ BIND_ADDRESS = '0.0.0.0' PORT = 9191 HSTS_ENABLED = False OFFLINE_MODE = False +FILESYSTEM_SESSIONS_ENABLED = False ### DATABASE CONFIG SQLA_DB_USER = 'pda' diff --git a/requirements.txt b/requirements.txt index cbcce1f..2fce905 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,3 +27,4 @@ pytimeparse==1.1.8 PyYAML==5.3.1 Flask-SSLify==0.1.5 Flask-Mail==0.9.1 +flask-session==0.3.2 \ No newline at end of file