Add checking for localhost in hostname fields.
This commit is contained in:
parent
cc453e7d10
commit
3a3945779d
3 changed files with 25 additions and 6 deletions
|
@ -62,7 +62,7 @@
|
||||||
<td>
|
<td>
|
||||||
<span class="config-string-field" binding="config.SERVER_HOSTNAME"
|
<span class="config-string-field" binding="config.SERVER_HOSTNAME"
|
||||||
placeholder="Hostname (and optional port if non-standard)"
|
placeholder="Hostname (and optional port if non-standard)"
|
||||||
pattern="^[a-zA-Z-0-9\.]+(:[0-9]+)?$"></span>
|
pattern="{{ HOSTNAME_REGEX }}"></span>
|
||||||
<div class="help-text">
|
<div class="help-text">
|
||||||
The HTTP host (and optionally the port number if a non-standard HTTP/HTTPS port) of the location
|
The HTTP host (and optionally the port number if a non-standard HTTP/HTTPS port) of the location
|
||||||
where the registry will be accessible on the network
|
where the registry will be accessible on the network
|
||||||
|
@ -121,7 +121,8 @@
|
||||||
<td>
|
<td>
|
||||||
<span class="config-string-field" binding="mapped.redis.host"
|
<span class="config-string-field" binding="mapped.redis.host"
|
||||||
placeholder="The redis server hostname"
|
placeholder="The redis server hostname"
|
||||||
pattern="^[a-zA-Z-0-9\.]+(:[0-9]+)?$"></span>
|
pattern="{{ HOSTNAME_REGEX }}"
|
||||||
|
validator="validateHostname(value)">></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -216,7 +217,8 @@
|
||||||
<td>
|
<td>
|
||||||
<span class="config-string-field" binding="config.MAIL_SERVER"
|
<span class="config-string-field" binding="config.MAIL_SERVER"
|
||||||
placeholder="SMTP server for sending e-mail"
|
placeholder="SMTP server for sending e-mail"
|
||||||
pattern="^[a-zA-Z-0-9\.]+(:[0-9]+)?$"></span>
|
pattern="{{ HOSTNAME_REGEX }}"
|
||||||
|
validator="validateHostname(value)">></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -377,7 +379,7 @@
|
||||||
<span class="config-string-field"
|
<span class="config-string-field"
|
||||||
binding="config.GITHUB_LOGIN_CONFIG.GITHUB_ENDPOINT"
|
binding="config.GITHUB_LOGIN_CONFIG.GITHUB_ENDPOINT"
|
||||||
placeholder="https://my.githubserver"
|
placeholder="https://my.githubserver"
|
||||||
pattern="^https?://([a-zA-Z0-9]+\.?\/?)+$">
|
pattern="{{ GITHUB_REGEX }}">
|
||||||
</span>
|
</span>
|
||||||
<div class="help-text">
|
<div class="help-text">
|
||||||
The Github Enterprise endpoint. Must start with http:// or https://.
|
The Github Enterprise endpoint. Must start with http:// or https://.
|
||||||
|
@ -509,7 +511,7 @@
|
||||||
<span class="config-string-field"
|
<span class="config-string-field"
|
||||||
binding="config.GITHUB_TRIGGER_CONFIG.GITHUB_ENDPOINT"
|
binding="config.GITHUB_TRIGGER_CONFIG.GITHUB_ENDPOINT"
|
||||||
placeholder="https://my.githubserver"
|
placeholder="https://my.githubserver"
|
||||||
pattern="^https?://([a-zA-Z0-9]+\.?\/?)+$">
|
pattern="{{ GITHUB_REGEX }}">
|
||||||
</span>
|
</span>
|
||||||
<div class="help-text">
|
<div class="help-text">
|
||||||
The Github Enterprise endpoint. Must start with http:// or https://.
|
The Github Enterprise endpoint. Must start with http:// or https://.
|
||||||
|
|
|
@ -3,5 +3,8 @@
|
||||||
<input type="text" class="form-control" placeholder="{{ placeholder || '' }}"
|
<input type="text" class="form-control" placeholder="{{ placeholder || '' }}"
|
||||||
ng-model="binding" ng-trim="false" ng-minlength="1"
|
ng-model="binding" ng-trim="false" ng-minlength="1"
|
||||||
ng-pattern="getRegexp(pattern)" required>
|
ng-pattern="getRegexp(pattern)" required>
|
||||||
|
<div class="alert alert-danger" ng-show="errorMessage">
|
||||||
|
{{ errorMessage }}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,6 +10,9 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
'isActive': '=isActive'
|
'isActive': '=isActive'
|
||||||
},
|
},
|
||||||
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
|
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
|
||||||
|
$scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9\.]+(:[0-9]+)?$';
|
||||||
|
$scope.GITHUB_REGEX = '^https?://([a-zA-Z0-9]+\.?\/?)+$';
|
||||||
|
|
||||||
$scope.SERVICES = [
|
$scope.SERVICES = [
|
||||||
{'id': 'redis', 'title': 'Redis'},
|
{'id': 'redis', 'title': 'Redis'},
|
||||||
|
|
||||||
|
@ -69,6 +72,14 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.validateHostname = function(hostname) {
|
||||||
|
if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) {
|
||||||
|
return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.'
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.config = null;
|
$scope.config = null;
|
||||||
$scope.mapped = {
|
$scope.mapped = {
|
||||||
'$hasChanges': false
|
'$hasChanges': false
|
||||||
|
@ -719,7 +730,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
'binding': '=binding',
|
'binding': '=binding',
|
||||||
'placeholder': '@placeholder',
|
'placeholder': '@placeholder',
|
||||||
'pattern': '@pattern',
|
'pattern': '@pattern',
|
||||||
'defaultValue': '@defaultValue'
|
'defaultValue': '@defaultValue',
|
||||||
|
'validator': '&validator'
|
||||||
},
|
},
|
||||||
controller: function($scope, $element) {
|
controller: function($scope, $element) {
|
||||||
$scope.getRegexp = function(pattern) {
|
$scope.getRegexp = function(pattern) {
|
||||||
|
@ -733,6 +745,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
if (!binding && $scope.defaultValue) {
|
if (!binding && $scope.defaultValue) {
|
||||||
$scope.binding = $scope.defaultValue;
|
$scope.binding = $scope.defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.errorMessage = $scope.validator({'value': binding || ''});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue