From 5a8200f17a4d1168686ceaa8c77d72daf07b5fe9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 13 Oct 2016 14:49:29 -0400 Subject: [PATCH] Add option to properly handle external TLS Fixes #1984 --- .../directives/config/config-setup-tool.html | 38 +++++++++++-------- static/js/core-config-setup.js | 31 +++++++++++++++ util/config/validator.py | 6 +++ 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index 8cbc13b02..c86187488 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -110,24 +110,30 @@ - SSL: + TLS: - + -
- A valid SSL certificate and private key files are required to use this option. +
+ Running without TLS should not be used for production workloads!
-
- Enabling SSL also enables HTTP Strict Transport Security.
+
+ Terminating TLS outside of Quay Enterprise can result in unusual behavior if the external load balancer is not + configured properly. This option is not recommended for simple setups. Please contact support + if you encounter problems while using this option. +
+ +
+ Enabling TLS also enables HTTP Strict Transport Security.
This prevents downgrade attacks and cookie theft, but browsers will reject all future insecure connections on this hostname.
- +
Certificate: @@ -272,7 +278,7 @@ {{ field.placeholder }}
- @@ -495,7 +501,7 @@
Authentication: - @@ -739,7 +745,7 @@
GitHub: - @@ -887,7 +893,7 @@
GitHub: - @@ -997,7 +1003,7 @@
GitLab: - diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js index 4d9f5b138..c47ba2f77 100644 --- a/static/js/core-config-setup.js +++ b/static/js/core-config-setup.js @@ -479,6 +479,36 @@ angular.module("core-config-setup", ['angularFileUpload']) $scope.mapped['redis']['host'] = getKey(config, 'BUILDLOGS_REDIS.host') || getKey(config, 'USER_EVENTS_REDIS.host'); $scope.mapped['redis']['port'] = getKey(config, 'BUILDLOGS_REDIS.port') || getKey(config, 'USER_EVENTS_REDIS.port'); $scope.mapped['redis']['password'] = getKey(config, 'BUILDLOGS_REDIS.password') || getKey(config, 'USER_EVENTS_REDIS.password'); + + $scope.mapped['TLS_SETTING'] = 'none'; + if (config['PREFERRED_URL_SCHEME'] == 'https') { + if (config['EXTERNAL_TLS_TERMINATION'] === true) { + $scope.mapped['TLS_SETTING'] = 'external-tls'; + } else { + $scope.mapped['TLS_SETTING'] = 'internal-tls'; + } + } + }; + + var tlsSetter = function(value) { + if (value == null || !$scope.config) { return; } + + switch (value) { + case 'none': + $scope.config['PREFERRED_URL_SCHEME'] = 'http'; + delete $scope.config['EXTERNAL_TLS_TERMINATION']; + return; + + case 'external-tls': + $scope.config['PREFERRED_URL_SCHEME'] = 'https'; + $scope.config['EXTERNAL_TLS_TERMINATION'] = true; + return; + + case 'internal-tls': + $scope.config['PREFERRED_URL_SCHEME'] = 'https'; + delete $scope.config['EXTERNAL_TLS_TERMINATION']; + return; + } }; var redisSetter = function(keyname) { @@ -508,6 +538,7 @@ angular.module("core-config-setup", ['angularFileUpload']) $scope.$watch('mapped.GITHUB_LOGIN_KIND', githubSelector('GITHUB_LOGIN_CONFIG')); $scope.$watch('mapped.GITHUB_TRIGGER_KIND', githubSelector('GITHUB_TRIGGER_CONFIG')); $scope.$watch('mapped.GITLAB_TRIGGER_KIND', gitlabSelector('GITLAB_TRIGGER_KIND')); + $scope.$watch('mapped.TLS_SETTING', tlsSetter); $scope.$watch('mapped.redis.host', redisSetter('host')); $scope.$watch('mapped.redis.port', redisSetter('port')); diff --git a/util/config/validator.py b/util/config/validator.py index 73696aa26..e824b210c 100644 --- a/util/config/validator.py +++ b/util/config/validator.py @@ -242,9 +242,15 @@ def _validate_google_login(config, _): def _validate_ssl(config, _): """ Validates the SSL configuration (if enabled). """ + + # Skip if non-SSL. if config.get('PREFERRED_URL_SCHEME', 'http') != 'https': return + # Skip if externally terminated. + if config.get('EXTERNAL_TLS_TERMINATION', False) == True: + return + for filename in SSL_FILENAMES: if not config_provider.volume_file_exists(filename): raise Exception('Missing required SSL file: %s' % filename)