Support multiple Flask session types, not just filesystem. Set via generic SESSION_TYPE environment variable

This commit is contained in:
Rauno Tuul 2023-03-08 12:08:07 +02:00
parent 5f2fc514df
commit 68d9fb3755
5 changed files with 9 additions and 10 deletions

View File

@ -24,7 +24,7 @@ CAPTCHA_SESSION_KEY = 'captcha_image'
#Server side sessions tracking #Server side sessions tracking
#Set to TRUE for CAPTCHA, or enable another stateful session tracking system #Set to TRUE for CAPTCHA, or enable another stateful session tracking system
FILESYSTEM_SESSIONS_ENABLED = True SESSION_TYPE = 'filesystem'
### DATABASE - MySQL ### DATABASE - MySQL
#SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}/{}'.format( #SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}/{}'.format(

View File

@ -4,7 +4,7 @@ PORT = 80
SQLALCHEMY_DATABASE_URI = 'sqlite:////data/powerdns-admin.db' SQLALCHEMY_DATABASE_URI = 'sqlite:////data/powerdns-admin.db'
SESSION_COOKIE_SAMESITE = 'Lax' SESSION_COOKIE_SAMESITE = 'Lax'
CSRF_COOKIE_HTTPONLY = True CSRF_COOKIE_HTTPONLY = True
FILESYSTEM_SESSIONS_ENABLED = True SESSION_TYPE = 'filesystem'
legal_envvars = ( legal_envvars = (
'SECRET_KEY', 'SECRET_KEY',
@ -68,7 +68,7 @@ legal_envvars = (
'LDAP_ENABLED', 'LDAP_ENABLED',
'SAML_CERT', 'SAML_CERT',
'SAML_KEY', 'SAML_KEY',
'FILESYSTEM_SESSIONS_ENABLED', 'SESSION_TYPE',
'SESSION_COOKIE_SECURE', 'SESSION_COOKIE_SECURE',
'CSRF_COOKIE_SECURE', 'CSRF_COOKIE_SECURE',
'CAPTCHA_ENABLE', 'CAPTCHA_ENABLE',
@ -93,7 +93,7 @@ legal_envvars_bool = (
'SIGNUP_ENABLED', 'SIGNUP_ENABLED',
'LOCAL_DB_ENABLED', 'LOCAL_DB_ENABLED',
'LDAP_ENABLED', 'LDAP_ENABLED',
'FILESYSTEM_SESSIONS_ENABLED', 'SESSION_TYPE',
'SESSION_COOKIE_SECURE', 'SESSION_COOKIE_SECURE',
'CSRF_COOKIE_SECURE', 'CSRF_COOKIE_SECURE',
'CAPTCHA_ENABLE', 'CAPTCHA_ENABLE',

View File

@ -4,7 +4,7 @@
| ---------| ----------- | -------- | ------------- | | ---------| ----------- | -------- | ------------- |
| BIND_ADDRESS | | BIND_ADDRESS |
| CSRF_COOKIE_SECURE | | CSRF_COOKIE_SECURE |
| FILESYSTEM_SESSIONS_ENABLED | | SESSION_TYPE | null|filesystem|sqlalchemy | | filesystem |
| LDAP_ENABLED | | LDAP_ENABLED |
| LOCAL_DB_ENABLED | | LOCAL_DB_ENABLED |
| LOG_LEVEL | | LOG_LEVEL |

View File

@ -56,10 +56,8 @@ def create_app(config=None):
_sslify = SSLify(app) # lgtm [py/unused-local-variable] _sslify = SSLify(app) # lgtm [py/unused-local-variable]
# Load Flask-Session # Load Flask-Session
if app.config.get('FILESYSTEM_SESSIONS_ENABLED'): sess = Session()
app.config['SESSION_TYPE'] = 'filesystem' sess.init_app(app)
sess = Session()
sess.init_app(app)
# SMTP # SMTP
app.mail = Mail(app) app.mail = Mail(app)

View File

@ -8,7 +8,8 @@ SECRET_KEY = 'e951e5a1f4b94151b360f47edf596dd2'
BIND_ADDRESS = '0.0.0.0' BIND_ADDRESS = '0.0.0.0'
PORT = 9191 PORT = 9191
HSTS_ENABLED = False HSTS_ENABLED = False
FILESYSTEM_SESSIONS_ENABLED = True
SESSION_TYPE = 'filesystem'
SESSION_COOKIE_SAMESITE = 'Lax' SESSION_COOKIE_SAMESITE = 'Lax'
CSRF_COOKIE_HTTPONLY = True CSRF_COOKIE_HTTPONLY = True