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>
|
||||
<span class="config-string-field" binding="config.SERVER_HOSTNAME"
|
||||
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">
|
||||
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
|
||||
|
@ -121,7 +121,8 @@
|
|||
<td>
|
||||
<span class="config-string-field" binding="mapped.redis.host"
|
||||
placeholder="The redis server hostname"
|
||||
pattern="^[a-zA-Z-0-9\.]+(:[0-9]+)?$"></span>
|
||||
pattern="{{ HOSTNAME_REGEX }}"
|
||||
validator="validateHostname(value)">></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -216,7 +217,8 @@
|
|||
<td>
|
||||
<span class="config-string-field" binding="config.MAIL_SERVER"
|
||||
placeholder="SMTP server for sending e-mail"
|
||||
pattern="^[a-zA-Z-0-9\.]+(:[0-9]+)?$"></span>
|
||||
pattern="{{ HOSTNAME_REGEX }}"
|
||||
validator="validateHostname(value)">></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -377,7 +379,7 @@
|
|||
<span class="config-string-field"
|
||||
binding="config.GITHUB_LOGIN_CONFIG.GITHUB_ENDPOINT"
|
||||
placeholder="https://my.githubserver"
|
||||
pattern="^https?://([a-zA-Z0-9]+\.?\/?)+$">
|
||||
pattern="{{ GITHUB_REGEX }}">
|
||||
</span>
|
||||
<div class="help-text">
|
||||
The Github Enterprise endpoint. Must start with http:// or https://.
|
||||
|
@ -509,7 +511,7 @@
|
|||
<span class="config-string-field"
|
||||
binding="config.GITHUB_TRIGGER_CONFIG.GITHUB_ENDPOINT"
|
||||
placeholder="https://my.githubserver"
|
||||
pattern="^https?://([a-zA-Z0-9]+\.?\/?)+$">
|
||||
pattern="{{ GITHUB_REGEX }}">
|
||||
</span>
|
||||
<div class="help-text">
|
||||
The Github Enterprise endpoint. Must start with http:// or https://.
|
||||
|
|
|
@ -3,5 +3,8 @@
|
|||
<input type="text" class="form-control" placeholder="{{ placeholder || '' }}"
|
||||
ng-model="binding" ng-trim="false" ng-minlength="1"
|
||||
ng-pattern="getRegexp(pattern)" required>
|
||||
<div class="alert alert-danger" ng-show="errorMessage">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -10,6 +10,9 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
'isActive': '=isActive'
|
||||
},
|
||||
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 = [
|
||||
{'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.mapped = {
|
||||
'$hasChanges': false
|
||||
|
@ -719,7 +730,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
'binding': '=binding',
|
||||
'placeholder': '@placeholder',
|
||||
'pattern': '@pattern',
|
||||
'defaultValue': '@defaultValue'
|
||||
'defaultValue': '@defaultValue',
|
||||
'validator': '&validator'
|
||||
},
|
||||
controller: function($scope, $element) {
|
||||
$scope.getRegexp = function(pattern) {
|
||||
|
@ -733,6 +745,8 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
|||
if (!binding && $scope.defaultValue) {
|
||||
$scope.binding = $scope.defaultValue;
|
||||
}
|
||||
|
||||
$scope.errorMessage = $scope.validator({'value': binding || ''});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue