From 9c176a3d0b7b2b9b42dc5c8fa3ac7b6fdbf48c89 Mon Sep 17 00:00:00 2001 From: Slavek Kabrda Date: Apr 25 2018 13:55:49 +0000 Subject: Enable usage of flask-session extension Merges https://pagure.io/pagure/pull-request/3181 --- diff --git a/doc/configuration.rst b/doc/configuration.rst index 6d97aa8..c8411dc 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -191,6 +191,21 @@ Defaults to: ``False`` for development, must be ``True`` in production with https. +SESSION_TYPE +~~~~~~~~~~~~ + +Enables the `flask-session `_ +extension if set to a value other than ``None``. The ``flask-session`` +package needs to be installed and proper +`configuration https://pythonhosted.org/Flask-Session/#configuration`_ +needs to be included in the Pagure config file. + +This is useful when the Pagure server needs to be scaled up to multiple +instances, which requires the flask session keys to be shared between those. +Flask-session allows you to use Redis, Memcached, relational database +or MongoDB for storing shared session keys. + + FROM_EMAIL ~~~~~~~~~~ diff --git a/pagure/flask_app.py b/pagure/flask_app.py index acbf2b8..75d558a 100644 --- a/pagure/flask_app.py +++ b/pagure/flask_app.py @@ -65,6 +65,10 @@ def create_app(config=None): if config: app.config.update(config) + if app.config.get('SESSION_TYPE', None) is not None: + import flask_session + flask_session.Session(app) + logging.basicConfig() logging.config.dictConfig(app.config.get('LOGGING') or {'version': 1}) diff --git a/requirements.txt b/requirements.txt index 2320795..2def484 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,6 +36,9 @@ wtforms # Required only for the `oidc` authentication backend # flask-oidc +# Required only if `USE_FLASK_SESSION_EXT` is set to `True` +# flask-session + # Required only for the `fas` and `openid` authentication backends # python-fedora