mirror of
https://git.proxmox.com/git/proxmox-acme
synced 2025-04-29 10:26:10 +00:00
Refactor extract_callenge for code reuse.
Signed-off-by: Wolfgang Link <w.link@proxmox.com>
This commit is contained in:
parent
5460050ded
commit
762af3b15c
@ -3,10 +3,57 @@ package PVE::ACME::Challenge;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
|
use PVE::JSONSchema qw(get_standard_option);
|
||||||
|
|
||||||
|
use base qw(PVE::SectionConfig);
|
||||||
|
|
||||||
|
my $defaultData = {
|
||||||
|
additionalProperties => 0,
|
||||||
|
propertyList => {
|
||||||
|
id => {
|
||||||
|
description => "ACME Plugin ID name",
|
||||||
|
type => 'string',
|
||||||
|
},
|
||||||
|
type => {
|
||||||
|
description => "ACME challenge type.",
|
||||||
|
type => 'string',
|
||||||
|
},
|
||||||
|
disable => {
|
||||||
|
description => "Flag to disable the config.",
|
||||||
|
type => 'boolean',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
nodes => get_standard_option('pve-node-list', { optional => 1 }),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
sub private {
|
||||||
|
return $defaultData;
|
||||||
|
}
|
||||||
|
|
||||||
sub supported_challenge_types {
|
sub supported_challenge_types {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub extract_challenge {
|
||||||
|
my ($self, $challenges, $c_type) = @_;
|
||||||
|
|
||||||
|
die "no challenges defined\n" if !$challenges;
|
||||||
|
die "no challenge type is defined \n" if !$c_type;
|
||||||
|
|
||||||
|
my $tmp_challenges = [ grep {$_->{type} eq $c_type} @$challenges ];
|
||||||
|
die "no $c_type challenge defined in authorization\n"
|
||||||
|
if ! scalar $tmp_challenges;
|
||||||
|
|
||||||
|
my $challenge = $tmp_challenges->[0];
|
||||||
|
|
||||||
|
return $challenge;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub get_subplugins {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
sub setup {
|
sub setup {
|
||||||
my ($class, $acme, $authorization) = @_;
|
my ($class, $acme, $authorization) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user