Commit 03351ec4 authored by Jacek Lebioda's avatar Jacek Lebioda
Browse files

Flask-session checks in the server start-up procedure

parent beb472d6
Pipeline #10617 passed with stage
in 49 seconds
......@@ -35,7 +35,12 @@ def register_extensions(app):
extensions.cors.init_app(app)
logger.debug(' * registering CORS succeeded!')
logger.debug(' * registering Flask-Session...')
extensions.flask_session.init_app(app)
extensions.check_flask_session_configuration(app.config)
try:
extensions.flask_session.init_app(app)
except ValueError:
logger.debug(' * failed to register Flask-Session!')
logger.debug(' Does your flask_settings.json contain `SESSION_TYPE` key?')
logger.debug(' * registering Flask-Session succeeded!')
logger.debug(' * registering OIDC...')
try:
......@@ -43,7 +48,6 @@ def register_extensions(app):
# Being really verbose here, as the OIDC extension likes not to work
# (usually because something is wrong with `client_secrets.json` file
logger.debug(' * registering OIDC succeeded!')
logger.debug(' * Registering extensions succeeded!')
except KeyError as e:
logger.error(' * failed to register OIDC extension!')
logger.error(' No `OIDC_CLIENT_SECRETS` key in Flask''s configuration!')
......@@ -57,13 +61,14 @@ def register_extensions(app):
logger.error(' Unspecified exception:')
logger.error(' ' + str(e.__class__))
raise e
logger.debug(' * Extensions successfully registered!')
def create_app(path_to_config_file=""):
"""
Creates the Flask application based on config object (Flask)
passed as an argument
:param config_object: used to configure Flask instance
:param path_to_config_file: path to a JSON file used to configure Flask instance
:return: Flask application object
"""
......
......@@ -2,7 +2,15 @@
from flask_cors import CORS
from flask_oidc import OpenIDConnect
from flask.ext.session import Session
from flask_session import Session
def check_flask_session_configuration(configuration):
"""
In order to start, Flask-Session require SESSION_TYPE to be present in the configuration
"""
if 'SESSION_TYPE' not in configuration:
raise ValueError("`SESSION_TYPE` not present in Flask Configuration")
cors = CORS()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment