Skip to content

Commit

Permalink
fix(config): read secret key from env (#475)
Browse files Browse the repository at this point in the history
Make sure the secret key is propagated to the Flask app, instead of
incorrectly using the default one.
  • Loading branch information
mdonadoni committed Nov 22, 2024
1 parent eb07aa9 commit e3218dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 9 additions & 0 deletions reana_job_controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@
"""Flask application configuration."""

import os
import secrets

from reana_commons.config import REANA_COMPONENT_PREFIX

from werkzeug.utils import import_string


SECRET_KEY = os.getenv("REANA_SECRET_KEY", secrets.token_hex())
"""Secret key used for the application user sessions.
A new random key is generated on every start of job-controller, but this is not an
issues as job-controller is never restarted (and thus the secret never changes)
during the execution of a single workflow."""

CACHE_ENABLED = False
"""Determines if jobs caching is enabled."""

Expand Down
1 change: 0 additions & 1 deletion reana_job_controller/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def create_app(config_mapping=None):
"""Create REANA-Job-Controller application."""
logging.basicConfig(level=REANA_LOG_LEVEL, format=REANA_LOG_FORMAT)
app = Flask(__name__)
app.secret_key = "mega secret key"
app.session = Session
app.config.from_object(config)
if config_mapping:
Expand Down

0 comments on commit e3218dc

Please sign in to comment.