From 637f6e78540d868a36eecb8dd94053e306261cd5 Mon Sep 17 00:00:00 2001 From: Maxime Date: Thu, 20 Aug 2015 17:31:02 +0000 Subject: [PATCH] Displaying message notifying users that Connections are stored in clear if cryptography package isn't available --- airflow/www/app.py | 15 +++++++++++++++ airflow/www/templates/airflow/conn_list.html | 9 +++++++++ 2 files changed, 24 insertions(+) create mode 100644 airflow/www/templates/airflow/conn_list.html diff --git a/airflow/www/app.py b/airflow/www/app.py index 5c879892f923e..0b18a40247943 100644 --- a/airflow/www/app.py +++ b/airflow/www/app.py @@ -1625,6 +1625,7 @@ class TaskInstanceModelView(ModelViewOnly): class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView): create_template = 'airflow/conn_create.html' edit_template = 'airflow/conn_edit.html' + list_template = 'airflow/conn_list.html' verbose_name = "Connection" verbose_name_plural = "Connections" column_default_sort = ('conn_id', False) @@ -1667,6 +1668,20 @@ def on_model_change(self, form, model, is_created): for key in self.form_extra_fields.keys() if key in formdata} model.extra = json.dumps(extra) + @classmethod + def is_secure(self): + """ + Used to display a message in the Connection list view making it clear + that the passwords can't be encrypted. + """ + is_secure = False + try: + import cryptography + is_secure = True + except: + pass + return is_secure + def on_form_prefill(self, form, id): try: d = json.loads(form.data.get('extra', '{}')) diff --git a/airflow/www/templates/airflow/conn_list.html b/airflow/www/templates/airflow/conn_list.html new file mode 100644 index 0000000000000..53a89fee06eba --- /dev/null +++ b/airflow/www/templates/airflow/conn_list.html @@ -0,0 +1,9 @@ +{% extends 'airflow/model_list.html' %} + +{% block model_menu_bar %} +{% if not admin_view.is_secure() %} +
Warning: Connection password are stored in clear until you install the Python "cryptography" library. Find the instructions on how to install it here: https://cryptography.io/en/latest/installation/
+{% endif %} + {{ super() }} +{% endblock %} +