Merge branch 'master' into generalizing-api

This commit is contained in:
Hossein Shafagh
2019-06-20 16:13:04 -07:00
committed by GitHub
11 changed files with 83 additions and 46 deletions

View File

@ -52,7 +52,7 @@ def get_certificates(exclude=None):
certs = []
for c in windowed_query(q, Certificate.id, 100):
for c in windowed_query(q, Certificate.id, 10000):
if needs_notification(c):
certs.append(c)
@ -140,12 +140,6 @@ def send_expiration_notifications(exclude):
notification_data.append(cert_data)
security_data.append(cert_data)
notification_recipient = get_plugin_option(
"recipients", notification.options
)
if notification_recipient:
notification_recipient = notification_recipient.split(",")
if send_notification(
"expiration", notification_data, [owner], notification
):
@ -153,10 +147,16 @@ def send_expiration_notifications(exclude):
else:
failure += 1
notification_recipient = get_plugin_option(
"recipients", notification.options
)
if notification_recipient:
notification_recipient = notification_recipient.split(",")
# removing owner and security_email from notification_recipient
notification_recipient = [i for i in notification_recipient if i not in security_email and i != owner]
if (
notification_recipient
and owner != notification_recipient
and security_email != notification_recipient
):
if send_notification(
"expiration",

View File

@ -67,14 +67,14 @@ class VaultSourcePlugin(SourcePlugin):
"name": "vaultPath",
"type": "str",
"required": True,
"validation": "^([a-zA-Z0-9_-]+/?)+$",
"validation": "^([a-zA-Z0-9._-]+/?)+$",
"helpMessage": "Must be a valid Vault secrets path",
},
{
"name": "objectName",
"type": "str",
"required": True,
"validation": "[0-9a-zA-Z:_-]+",
"validation": "[0-9a-zA-Z.:_-]+",
"helpMessage": "Object Name to search",
},
]
@ -177,14 +177,14 @@ class VaultDestinationPlugin(DestinationPlugin):
"name": "vaultPath",
"type": "str",
"required": True,
"validation": "^([a-zA-Z0-9_-]+/?)+$",
"validation": "^([a-zA-Z0-9._-]+/?)+$",
"helpMessage": "Must be a valid Vault secrets path",
},
{
"name": "objectName",
"type": "str",
"required": False,
"validation": "[0-9a-zA-Z:_-]+",
"validation": "[0-9a-zA-Z.:_-]+",
"helpMessage": "Name to bundle certs under, if blank use cn",
},
{

View File

@ -33,6 +33,8 @@
uib-tooltip="If you need a certificate with multiple domains enter your primary domain here and the rest under 'Subject Alternate Names' by clicking 'More Options'"
ng-model="certificate.commonName" placeholder="Common Name" class="form-control"
ng-maxlength="64"
ng-blur="certificate.attachCommonName()"
ng-focus="certificate.removeCommonName()"
required/>
<p ng-show="trackingForm.commonName.$invalid && !trackingForm.commonName.$pristine" class="help-block">

View File

@ -18,6 +18,26 @@ angular.module('lemur')
this.authority = authority;
this.authority.maxDate = moment(this.authority.notAfter).subtract(1, 'days').format('YYYY/MM/DD');
},
attachCommonName: function () {
if (this.extensions === undefined) {
this.extensions = {};
}
if (this.extensions.subAltNames === undefined) {
this.extensions.subAltNames = {'names': []};
}
if (angular.isString(this.commonName)) {
this.extensions.subAltNames.names.unshift({'nameType': 'DNSName', 'value': this.commonName});
}
},
removeCommonName: function () {
if (angular.isDefined(this.extensions) && angular.isDefined(this.extensions.subAltNames)) {
if (angular.equals(this.extensions.subAltNames.names[0].value, this.commonName)) {
this.extensions.subAltNames.names.shift();
}
}
},
attachSubAltName: function () {
if (this.extensions === undefined) {
this.extensions = {};

View File

@ -17,7 +17,7 @@ angular.module('lemur')
});
})
.controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) {
.controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, $location, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) {
$scope.filter = $stateParams;
$scope.certificateTable = new ngTableParams({
page: 1, // show first page
@ -29,11 +29,24 @@ angular.module('lemur')
}, {
total: 0, // length of data
getData: function ($defer, params) {
CertificateApi.getList(params.url())
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
$scope.path = $location.path();
// Handle Permalink clicks through a separate API
// Clicking on Permalink adds the certificate name to the URL after "certificates/", which is used to identify the click
if ($scope.path.indexOf('certificates/') > -1 && $scope.path.split('/')[2].length > 0) {
$scope.certificateName = $scope.path.split('/')[2];
CertificateApi.one('name').one($scope.certificateName).getList()
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
else {
CertificateApi.getList(params.url())
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
}
});