Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-2884] Fix Flask SECRET_KEY security issue in www_rbac #3729

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ worker_refresh_batch_size = 1
worker_refresh_interval = 30

# Secret key used to run your flask app
# If default value is given ("temporary_key"), a random secret_key will be generated
# when you launch your webserver for security reason
secret_key = temporary_key

# Number of workers to run the Gunicorn web server
Expand Down
6 changes: 5 additions & 1 deletion airflow/www_rbac/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#
import socket
import six
import os

from flask import Flask
from flask_appbuilder import AppBuilder, SQLA
Expand All @@ -42,7 +43,10 @@ def create_app(config=None, session=None, testing=False, app_name="Airflow"):
global app, appbuilder
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app)
app.secret_key = conf.get('webserver', 'SECRET_KEY')
if conf.get('webserver', 'SECRET_KEY') == "temporary_key":
app.secret_key = os.urandom(16)
else:
app.secret_key = conf.get('webserver', 'SECRET_KEY')

airflow_home_path = conf.get('core', 'AIRFLOW_HOME')
webserver_config_path = airflow_home_path + '/webserver_config.py'
Expand Down