Add option to properly handle external TLS

Fixes #1984
This commit is contained in:
Joseph Schorr 2016-10-13 14:49:29 -04:00
parent ca4cc3d5b5
commit 5a8200f17a
3 changed files with 59 additions and 16 deletions

View file

@ -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'));