Calculate dates from defaultDays in js
This commit is contained in:
parent
3242fc1e13
commit
9c4fb85dc3
|
@ -174,9 +174,10 @@ Specifying the `SQLALCHEMY_MAX_OVERFLOW` to 0 will enforce limit to not create c
|
||||||
|
|
||||||
.. data:: DEFAULT_VALIDITY_DAYS
|
.. data:: DEFAULT_VALIDITY_DAYS
|
||||||
:noindex:
|
:noindex:
|
||||||
Use this config to override the default validity of certificates offered through Lemur UI. Any CA which is not listed
|
Use this config to override the default validity of 365 days for certificates offered through Lemur UI. Any CA which
|
||||||
in PUBLIC_CA_AUTHORITY_NAMES will be using this value as default validity to be displayed on UI. Below example overrides the
|
is not listed in PUBLIC_CA_AUTHORITY_NAMES will be using this value as default validity to be displayed on UI. Please
|
||||||
default validity of 365 days and sets it to 1095 days (3 years).
|
note that this config is used for cert issuance only through Lemur UI. Below example overrides the default validity
|
||||||
|
of 365 days and sets it to 1095 days (3 years).
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
|
|
@ -139,11 +139,13 @@ angular.module('lemur')
|
||||||
);
|
);
|
||||||
|
|
||||||
$scope.create = function (certificate) {
|
$scope.create = function (certificate) {
|
||||||
if(certificate.validityType === 'dates' &&
|
if(certificate.validityType === 'customDates' &&
|
||||||
(!certificate.validityStart || !certificate.validityEnd)) { // these are not mandatory fields in schema, thus handling validation in js
|
(!certificate.validityStart || !certificate.validityEnd)) { // these are not mandatory fields in schema, thus handling validation in js
|
||||||
return showMissingDateError();
|
return showMissingDateError();
|
||||||
}
|
}
|
||||||
delete certificate.validityType;
|
if(certificate.validityType === 'defaultDays') {
|
||||||
|
populateValidityDateAsPerDefault(certificate);
|
||||||
|
}
|
||||||
|
|
||||||
WizardHandler.wizard().context.loading = true;
|
WizardHandler.wizard().context.loading = true;
|
||||||
CertificateService.create(certificate).then(
|
CertificateService.create(certificate).then(
|
||||||
|
@ -183,7 +185,14 @@ angular.module('lemur')
|
||||||
directiveData: error,
|
directiveData: error,
|
||||||
timeout: 100000
|
timeout: 100000
|
||||||
});
|
});
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
function populateValidityDateAsPerDefault(certificate) {
|
||||||
|
// calculate start and end date as per default validity
|
||||||
|
let startDate = new Date(), endDate = new Date();
|
||||||
|
endDate.setDate(startDate.getDate() + certificate.authority.authorityCertificate.defaultValidityDays);
|
||||||
|
certificate.validityStart = startDate;
|
||||||
|
certificate.validityEnd = endDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.templates = [
|
$scope.templates = [
|
||||||
|
@ -299,6 +308,14 @@ angular.module('lemur')
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.create = function (certificate) {
|
$scope.create = function (certificate) {
|
||||||
|
if(certificate.validityType === 'customDates' &&
|
||||||
|
(!certificate.validityStart || !certificate.validityEnd)) { // these are not mandatory fields in schema, thus handling validation in js
|
||||||
|
return showMissingDateError();
|
||||||
|
}
|
||||||
|
if(certificate.validityType === 'defaultDays') {
|
||||||
|
populateValidityDateAsPerDefault(certificate);
|
||||||
|
}
|
||||||
|
|
||||||
WizardHandler.wizard().context.loading = true;
|
WizardHandler.wizard().context.loading = true;
|
||||||
CertificateService.create(certificate).then(
|
CertificateService.create(certificate).then(
|
||||||
function () {
|
function () {
|
||||||
|
@ -323,6 +340,30 @@ angular.module('lemur')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function showMissingDateError() {
|
||||||
|
let error = {};
|
||||||
|
error.message = '';
|
||||||
|
error.reasons = {};
|
||||||
|
error.reasons.validityRange = 'Valid start and end dates are needed, else select Default option';
|
||||||
|
|
||||||
|
toaster.pop({
|
||||||
|
type: 'error',
|
||||||
|
title: 'Validation Error',
|
||||||
|
body: 'lemur-bad-request',
|
||||||
|
bodyOutputType: 'directive',
|
||||||
|
directiveData: error,
|
||||||
|
timeout: 100000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateValidityDateAsPerDefault(certificate) {
|
||||||
|
// calculate start and end date as per default validity
|
||||||
|
let startDate = new Date(), endDate = new Date();
|
||||||
|
endDate.setDate(startDate.getDate() + certificate.authority.authorityCertificate.defaultValidityDays);
|
||||||
|
certificate.validityStart = startDate;
|
||||||
|
certificate.validityEnd = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.templates = [
|
$scope.templates = [
|
||||||
{
|
{
|
||||||
'name': 'Client Certificate',
|
'name': 'Client Certificate',
|
||||||
|
|
|
@ -133,17 +133,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" ng-hide="certificate.authority.plugin.slug == 'acme-issuer'">
|
<div class="form-group" ng-hide="certificate.authority.plugin.slug == 'acme-issuer'">
|
||||||
<label class="control-label col-sm-2"
|
<label class="control-label col-sm-2"
|
||||||
uib-tooltip="If no date is selected Lemur attempts to issue a 1 year certificate">
|
uib-tooltip="You can select custom date range, however we recommend continuing with default validity.">
|
||||||
Validity Range <span class="glyphicon glyphicon-question-sign"></span>
|
Validity Range <span class="glyphicon glyphicon-question-sign"></span>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<div class="btn-group">
|
<div class="btn-group btn-group-toggle" data-toggle="buttons">
|
||||||
<label class="btn btn-success" ng-model="certificate.validityType" uib-btn-radio="'defaultDays'" ng-click="clearDates()">
|
<label class="btn btn-info" ng-model="certificate.validityType" uib-btn-radio="'defaultDays'" ng-click="clearDates()">
|
||||||
Default ({{certificate.authority.authorityCertificate.defaultValidityDays}} days)</label>
|
Default ({{certificate.authority.authorityCertificate.defaultValidityDays}} days)</label>
|
||||||
<label class="btn btn-success" ng-model="certificate.validityType" uib-btn-radio="'dates'">Select Date</label>
|
<label class="btn btn-info" ng-model="certificate.validityType" uib-btn-radio="'customDates'" ng-change="clearDates()">Custom</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3" ng-if="certificate.validityType==='dates'">
|
<div class="col-sm-3" ng-if="certificate.validityType==='customDates'">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control"
|
<input type="text" class="form-control"
|
||||||
uib-tooltip="Start Date (yyyy/MM/dd)"
|
uib-tooltip="Start Date (yyyy/MM/dd)"
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3" ng-if="certificate.validityType==='dates'">
|
<div class="col-sm-3" ng-if="certificate.validityType==='customDates'">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control"
|
<input type="text" class="form-control"
|
||||||
uib-tooltip="End Date (yyyy/MM/dd)"
|
uib-tooltip="End Date (yyyy/MM/dd)"
|
||||||
|
|
Loading…
Reference in New Issue