Merge branch 'master' into restore-manage-shebang

This commit is contained in:
Hossein Shafagh 2019-06-25 09:27:08 -07:00 committed by GitHub
commit 404b7a25bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 50 additions and 12 deletions

View File

@ -329,12 +329,14 @@ def render(args):
""" """
query = database.session_query(Certificate) query = database.session_query(Certificate)
time_range = args.pop("time_range") show_expired = args.pop("showExpired")
if not time_range: if show_expired != 1:
six_month_old = arrow.now()\ one_month_old = arrow.now()\
.shift(months=current_app.config.get("HIDE_EXPIRED_CERTS_AFTER_MONTHS", -6))\ .shift(months=current_app.config.get("HIDE_EXPIRED_CERTS_AFTER_MONTHS", -1))\
.format("YYYY-MM-DD") .format("YYYY-MM-DD")
query = query.filter(Certificate.not_after > six_month_old) query = query.filter(Certificate.not_after > one_month_old)
time_range = args.pop("time_range")
destination_id = args.pop("destination_id") destination_id = args.pop("destination_id")
notification_id = args.pop("notification_id", None) notification_id = args.pop("notification_id", None)
@ -445,7 +447,7 @@ def query_name(certificate_name, args):
def query_common_name(common_name, args): def query_common_name(common_name, args):
""" """
Helper function that queries for not expired certificates by common name and owner which have auto-rotate enabled Helper function that queries for not expired certificates by common name (and owner)
:param common_name: :param common_name:
:param args: :param args:
@ -462,7 +464,6 @@ def query_common_name(common_name, args):
Certificate.query.filter(Certificate.cn.ilike(common_name)) Certificate.query.filter(Certificate.cn.ilike(common_name))
.filter(Certificate.owner.ilike(owner)) .filter(Certificate.owner.ilike(owner))
.filter(Certificate.not_after >= current_time.format("YYYY-MM-DD")) .filter(Certificate.not_after >= current_time.format("YYYY-MM-DD"))
.filter(Certificate.rotation.is_(True))
.all() .all()
) )

View File

@ -347,6 +347,7 @@ class CertificatesList(AuthenticatedResource):
) )
parser.add_argument("creator", type=str, location="args") parser.add_argument("creator", type=str, location="args")
parser.add_argument("show", type=str, location="args") parser.add_argument("show", type=str, location="args")
parser.add_argument("showExpired", type=int, location="args")
args = parser.parse_args() args = parser.parse_args()
args["user"] = g.user args["user"] = g.user

View File

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

View File

@ -30,7 +30,7 @@
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<input name="commonName" <input name="commonName"
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'" uib-tooltip="If you need a certificate with multiple domains enter your primary domain here and add additional 'DNSName' entries unders 'Subject Alternate Names' below"
ng-model="certificate.commonName" placeholder="Common Name" class="form-control" ng-model="certificate.commonName" placeholder="Common Name" class="form-control"
ng-maxlength="64" ng-maxlength="64"
ng-blur="certificate.attachCommonName()" ng-blur="certificate.attachCommonName()"

View File

@ -19,6 +19,9 @@ angular.module('lemur')
.controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, $location, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) { .controller('CertificatesViewController', function ($q, $scope, $uibModal, $stateParams, $location, CertificateApi, CertificateService, MomentService, ngTableParams, toaster) {
$scope.filter = $stateParams; $scope.filter = $stateParams;
$scope.expiredText = ['Show Expired', 'Hide Expired'];
$scope.expiredValue = 0;
$scope.expiredButton = $scope.expiredText[$scope.expiredValue];
$scope.certificateTable = new ngTableParams({ $scope.certificateTable = new ngTableParams({
page: 1, // show first page page: 1, // show first page
count: 10, // count per page count: 10, // count per page
@ -50,6 +53,34 @@ angular.module('lemur')
} }
}); });
$scope.showExpired = function () {
if ($scope.expiredValue === 0) {
$scope.expiredValue = 1;
}
else {
$scope.expiredValue = 0;
}
$scope.expiredButton = $scope.expiredText[$scope.expiredValue];
$scope.certificateTable = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
sorting: {
id: 'desc' // initial sorting
},
filter: $scope.filter
}, {
getData: function ($defer, params) {
$scope.temp = angular.copy(params.url());
$scope.temp.showExpired = $scope.expiredValue;
CertificateApi.getList($scope.temp)
.then(function (data) {
params.total(data.total);
$defer.resolve(data);
});
}
});
};
$scope.momentService = MomentService; $scope.momentService = MomentService;
$scope.remove = function (certificate) { $scope.remove = function (certificate) {

View File

@ -17,6 +17,11 @@
btn-checkbox-true="1" btn-checkbox-true="1"
btn-checkbox-false="0">Filter</button> btn-checkbox-false="0">Filter</button>
</div> </div>
<div class="btn-group">
<button ng-click="showExpired()" class="btn btn-info">
{{ expiredButton }}
</button>
</div>
<!--<select class="form-control" ng-model="show" ng-options="item.value as item.title for item in fields"></select>--> <!--<select class="form-control" ng-model="show" ng-options="item.value as item.title for item in fields"></select>-->
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>