Refactor destination selection for acme-http authorities, to load destinations dynamically
This commit is contained in:
parent
81b078604c
commit
235653b558
|
@ -721,7 +721,6 @@ class ACMEIssuerPlugin(IssuerPlugin):
|
||||||
account_number = None
|
account_number = None
|
||||||
provider_type = None
|
provider_type = None
|
||||||
|
|
||||||
acme_client.new_order()
|
|
||||||
domains = self.acme.get_domains(issuer_options)
|
domains = self.acme.get_domains(issuer_options)
|
||||||
if not create_immediately:
|
if not create_immediately:
|
||||||
# Create pending authorizations that we'll need to do the creation
|
# Create pending authorizations that we'll need to do the creation
|
||||||
|
@ -844,9 +843,8 @@ class ACMEHttpIssuerPlugin(IssuerPlugin):
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "tokenDestination",
|
"name": "tokenDestination",
|
||||||
"type": "select",
|
"type": "destinationSelect",
|
||||||
"required": True,
|
"required": True,
|
||||||
"available": destination_list,
|
|
||||||
"helpMessage": "The destination to use to deploy the token.",
|
"helpMessage": "The destination to use to deploy the token.",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -871,7 +869,6 @@ class ACMEHttpIssuerPlugin(IssuerPlugin):
|
||||||
"""
|
"""
|
||||||
self.acme = AcmeHandler()
|
self.acme = AcmeHandler()
|
||||||
authority = issuer_options.get("authority")
|
authority = issuer_options.get("authority")
|
||||||
create_immediately = issuer_options.get("create_immediately", False)
|
|
||||||
acme_client, registration = self.acme.setup_acme_client(authority)
|
acme_client, registration = self.acme.setup_acme_client(authority)
|
||||||
|
|
||||||
orderr = acme_client.new_order(csr)
|
orderr = acme_client.new_order(csr)
|
||||||
|
@ -888,12 +885,10 @@ class ACMEHttpIssuerPlugin(IssuerPlugin):
|
||||||
if len(chall) == 0:
|
if len(chall) == 0:
|
||||||
raise Exception('HTTP-01 challenge was not offered by the CA server.')
|
raise Exception('HTTP-01 challenge was not offered by the CA server.')
|
||||||
else:
|
else:
|
||||||
# Here we probably should create a pending certificate and make use of celery, but for now
|
|
||||||
# I'll ignore all of that
|
|
||||||
token_destination = None
|
token_destination = None
|
||||||
for option in json.loads(issuer_options["authority"].options):
|
for option in json.loads(issuer_options["authority"].options):
|
||||||
if option["name"] == "tokenDestination":
|
if option["name"] == "tokenDestination":
|
||||||
token_destination = destination_service.get_by_label(option["value"])
|
token_destination = destination_service.get(option["value"])
|
||||||
|
|
||||||
if token_destination is None:
|
if token_destination is None:
|
||||||
raise Exception('No token_destination configured for this authority. Cant complete HTTP-01 challenge')
|
raise Exception('No token_destination configured for this authority. Cant complete HTTP-01 challenge')
|
||||||
|
|
|
@ -34,7 +34,7 @@ angular.module('lemur')
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller('AuthorityCreateController', function ($scope, $uibModalInstance, AuthorityService, AuthorityApi, LemurRestangular, RoleService, PluginService, WizardHandler, toaster) {
|
.controller('AuthorityCreateController', function ($scope, $uibModalInstance, AuthorityService, AuthorityApi, LemurRestangular, RoleService, PluginService, WizardHandler, toaster, DestinationService) {
|
||||||
$scope.authority = LemurRestangular.restangularizeElement(null, {}, 'authorities');
|
$scope.authority = LemurRestangular.restangularizeElement(null, {}, 'authorities');
|
||||||
// set the defaults
|
// set the defaults
|
||||||
AuthorityService.getDefaults($scope.authority).then(function () {
|
AuthorityService.getDefaults($scope.authority).then(function () {
|
||||||
|
@ -52,6 +52,12 @@ angular.module('lemur')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.getDestinations = function() {
|
||||||
|
return DestinationService.findDestinationsByName('').then(function(destinations) {
|
||||||
|
$scope.destinations = destinations;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.getAuthoritiesByName = function (value) {
|
$scope.getAuthoritiesByName = function (value) {
|
||||||
return AuthorityService.findAuthorityByName(value).then(function (authorities) {
|
return AuthorityService.findAuthorityByName(value).then(function (authorities) {
|
||||||
$scope.authorities = authorities;
|
$scope.authorities = authorities;
|
||||||
|
|
|
@ -72,11 +72,28 @@
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input name="sub" ng-if="item.type == 'int'" type="number" ng-pattern="item.validation?item.validation:'^[0-9]+$'"
|
<input name="sub" ng-if="item.type == 'int'" type="number" ng-pattern="item.validation?item.validation:'^[0-9]+$'"
|
||||||
class="form-control" ng-model="item.value"/>
|
class="form-control" ng-model="item.value"/>
|
||||||
|
|
||||||
<select name="sub" ng-if="item.type == 'select'" class="form-control" ng-options="i for i in item.available"
|
<select name="sub" ng-if="item.type == 'select'" class="form-control" ng-options="i for i in item.available"
|
||||||
ng-model="item.value"></select>
|
ng-model="item.value"></select>
|
||||||
|
|
||||||
|
<!-- DestSelect options -->
|
||||||
|
<ui-select class="input-md" ng-model="item.value" theme="bootstrap" title="choose a destination" ng-if="item.type == 'destinationSelect'">
|
||||||
|
<ui-select-match placeholder="select an destination...">{{$select.selected.label}}</ui-select-match>
|
||||||
|
<ui-select-choices class="form-control"
|
||||||
|
refresh="getDestinations()"
|
||||||
|
refresh-delay="300"
|
||||||
|
repeat="destination.id as destination in destinations | filter: $select.search">
|
||||||
|
<div ng-bind-html="destination.label | highlight: $select.search"></div>
|
||||||
|
<small>
|
||||||
|
<span ng-bind-html="''+destination.description | highlight: $select.search"></span>
|
||||||
|
</small>
|
||||||
|
</ui-select-choices>
|
||||||
|
</ui-select>
|
||||||
|
|
||||||
<input name="sub" ng-if="item.type == 'bool'" class="form-control" type="checkbox" ng-model="item.value">
|
<input name="sub" ng-if="item.type == 'bool'" class="form-control" type="checkbox" ng-model="item.value">
|
||||||
<input name="sub" ng-if="item.type == 'str'" type="text" class="form-control" ng-model="item.value"/>
|
<input name="sub" ng-if="item.type == 'str'" type="text" class="form-control" ng-model="item.value"/>
|
||||||
<textarea name="sub" ng-if="item.type == 'textarea'" class="form-control" ng-model="item.value"></textarea>
|
<textarea name="sub" ng-if="item.type == 'textarea'" class="form-control" ng-model="item.value"></textarea>
|
||||||
|
|
||||||
<div ng-if="item.type == 'export-plugin'">
|
<div ng-if="item.type == 'export-plugin'">
|
||||||
<form name="exportForm" class="form-horizontal" role="form" novalidate>
|
<form name="exportForm" class="form-horizontal" role="form" novalidate>
|
||||||
<select class="form-control" ng-model="item.value"
|
<select class="form-control" ng-model="item.value"
|
||||||
|
|
Loading…
Reference in New Issue