Merge pull request #2274 from coreos-inc/custom-cert-management

Custom SSL certificates config panel
This commit is contained in:
josephschorr 2017-01-13 16:24:47 -05:00 committed by GitHub
commit ac8cddc5a9
14 changed files with 434 additions and 41 deletions

View file

@ -519,6 +519,37 @@ a:focus {
width: 350px;
}
.config-certificates-field-element .dns-name {
display: inline-block;
margin-right: 10px;
}
.config-certificates-field-element .cert-status .fa {
margin-right: 4px;
}
.config-certificates-field-element .cert-status .green {
color: #2FC98E;
}
.config-certificates-field-element .cert-status .orange {
color: #FCA657;
}
.config-certificates-field-element .cert-status .red {
color: #D64456;
}
.config-certificates-field-element .file-upload-box-element .file-input-container {
padding: 0px;
text-align: left;
}
.config-certificates-field-element .file-upload-box-element .file-drop + label {
margin-top: 0px;
margin-bottom: 4px;
}
.config-list-field-element .empty {
color: #ccc;
margin-bottom: 10px;

View file

@ -0,0 +1,70 @@
<div class="config-certificates-field-element">
<div class="resource-view" resource="certificatesResource" error-message="'Could not load certificates list'">
<!-- File -->
<div class="co-alert co-alert-warning" ng-if="certInfo.status == 'file'">
<code>extra_ca_certs</code> is a single file and cannot be processed by this tool. If a valid and appended list of certificates, they will be installed on container startup.
</div>
<div ng-if="certInfo.status != 'file'">
<div class="description">
<p>This section lists any custom or self-signed SSL certificates that are installed in the <span class="registry-name"></span> container on startup after being read from the <code>extra_ca_certs</code> directory in the configuration volume.
</p>
<p>
Custom certificates are typically used in place of publicly signed certificates for corporate-internal services.
</p>
</div>
<table class="config-table" style="margin-bottom: 20px;">
<tr>
<td>Upload certificates:</td>
<td>
<div class="file-upload-box"
select-message="Select custom certificate to add to configuration. Must be in PEM format."
files-selected="handleCertsSelected(files, callback)"
reset="resetUpload"></div>
</td>
</tr>
</table>
<table class="co-table">
<thead>
<td>Certificate Filename</td>
<td>Status</td>
<td>Names Handled</td>
<td class="options-col"></td>
</thead>
<tr ng-repeat="certificate in certInfo.certs">
<td>{{ certificate.path }}</td>
<td class="cert-status">
<div ng-if="certificate.error" class="red">
<i class="fa fa-exclamation-circle"></i>
Error: {{ certificate.error }}
</div>
<div ng-if="certificate.expired" class="orange">
<i class="fa fa-exclamation-triangle"></i>
Certificate is expired
</div>
<div ng-if="!certificate.error && !certificate.expired" class="green">
<i class="fa fa-check-circle"></i>
Certificate is valid
</div>
</td>
<td>
<div class="empty" ng-if="!certificate.names">(None)</div>
<a class="dns-name" ng-href="http://{{ name }}" ng-repeat="name in certificate.names" ng-safenewtab>{{ name }}</a>
</td>
<td class="options-col">
<span class="cor-options-menu">
<span class="cor-option" option-click="deleteCert(certificate.path)">
<i class="fa fa-times"></i> Delete Certificate
</span>
</span>
</td>
</tr>
</table>
<div class="empty" ng-if="!certInfo.certs.length" style="margin-top: 20px;">
<div class="empty-primary-msg">No custom certificates found.</div>
</div>
</div>
</div>
</div>

View file

@ -13,6 +13,16 @@
</div>
</div>
<!-- Custom SSL certificates -->
<div class="co-panel">
<div class="co-panel-heading">
<i class="fa fa-certificate"></i> Custom SSL Certificates
</div>
<div class="co-panel-body">
<div class="config-certificates-field"></div>
</div>
</div>
<!-- Basic Configuration -->
<div class="co-panel">
<div class="co-panel-heading">

View file

@ -1254,6 +1254,56 @@ angular.module("core-config-setup", ['angularFileUpload'])
return directiveDefinitionObject;
})
.directive('configCertificatesField', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/config/config-certificates-field.html',
replace: false,
transclude: false,
restrict: 'C',
scope: {
},
controller: function($scope, $element, $upload, ApiService, UserService) {
$scope.resetUpload = 0;
var loadCertificates = function() {
$scope.certificatesResource = ApiService.getCustomCertificatesAsResource().get(function(resp) {
$scope.certInfo = resp;
});
};
UserService.updateUserIn($scope, function(user) {
if (!user.anonymous) {
loadCertificates();
}
});
$scope.handleCertsSelected = function(files, callback) {
$upload.upload({
url: '/api/v1/superuser/customcerts/' + files[0].name,
method: 'POST',
data: {'_csrf_token': window.__token},
file: files[0]
}).success(function() {
callback(true);
$scope.resetUpload++;
loadCertificates();
});
};
$scope.deleteCert = function(path) {
var errorDisplay = ApiService.errorDisplay('Could not delete certificate');
var params = {
'certpath': path
};
ApiService.deleteCustomCertificate(null, params).then(loadCertificates, errorDisplay);
};
}
};
return directiveDefinitionObject;
})
.directive('configLicenseField', function () {
var directiveDefinitionObject = {
priority: 0,

View file

@ -9,7 +9,6 @@ angular.module('quay').directive('fileUploadBox', function () {
transclude: true,
restrict: 'C',
scope: {
'allowMultiple': '@allowMultiple',
'selectMessage': '@selectMessage',
'filesSelected': '&filesSelected',