Skip to content

Possibility to store data on the server side

Matthias Saimpert requested to merge irfu/devel-2.2_flask_session into devel-2.2

this MR allows the user to use mongoDB on the server side to store session data instead of the flask default (cookies on the client side).

this is useful when deploying localDB as e.g. a docker swarm service with multiple replicas, see e.g. https://testdriven.io/blog/flask-sessions/ for more info.

here is how it works:

  • if the user keeps his config file as is, the session data are still stored the old way, i.e. default flask method (cookies on the client side)
  • is the user adds the following fields in the flask section of the config the storage of session data on their mongoDB is turned on:
    • session: True
    • db: flask_db (mongoDB database used to store session data, needs to be configured by the user before hand manually)
    • KeyFile: (same mechanism as for the other fields) or username/password for the mongoDB authentification and writing on db used to store session data

full example (running on the Paris cluster regionalDB)

flask:
    host: 127.0.0.1 # IP address running app.py
    port: 5000      # port number running app.py
    cert: /run/secrets/certificate.pem
    key:  /run/secrets/private_keys.pem
    mail: True
    session: True
    db: flask_db
    KeyFile: /run/secrets/flasksession-key

Merge request reports