Skip to content

Commit

Permalink
Encryption tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Aug 28, 2015
1 parent 4b20b3d commit 7dfbde1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
DAGS_FOLDER = os.path.expanduser(conf.get('core', 'DAGS_FOLDER'))
XCOM_RETURN_KEY = 'return_value'

ENCRYPTION_ON = False
try:
from cryptography.fernet import Fernet
FERNET = Fernet(conf.get('core', 'FERNET_KEY'))
ENCRYPTION_ON = True
except:
pass

Expand Down Expand Up @@ -328,6 +330,9 @@ def __init__(

def get_password(self):
if self._password and self.is_encrypted:
if not ENCRYPTION_ON:
raise AirflowException(
"Can't decrypt, configuration is missing")
return FERNET.decrypt(bytes(self._password, 'utf-8'))
else:
return self._password
Expand Down
2 changes: 1 addition & 1 deletion airflow/www/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ class ConnectionModelView(wwwutils.SuperUserMixin, AirflowModelView):
verbose_name = "Connection"
verbose_name_plural = "Connections"
column_default_sort = ('conn_id', False)
column_list = ('conn_id', 'conn_type', 'host', 'port')
column_list = ('conn_id', 'conn_type', 'host', 'port', 'is_encrypted')
form_overrides = dict(_password=VisiblePasswordField)
form_widget_args = {
'is_encrypted': {'disabled': True},
Expand Down

0 comments on commit 7dfbde1

Please sign in to comment.