mirror of
https://git.proxmox.com/git/proxmox-acme
synced 2025-04-29 02:32:03 +00:00
plugins: unify extract_challenge
we have a list of supported challenge types per plugin, so we only need one generic implementation. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
f00829fd60
commit
122626b3d5
@ -48,22 +48,26 @@ sub parse_config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub supported_challenge_types {
|
sub supported_challenge_types {
|
||||||
return {};
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub extract_challenge {
|
sub extract_challenge {
|
||||||
my ($self, $challenges, $c_type) = @_;
|
my ($self, $challenges) = @_;
|
||||||
|
|
||||||
die "no challenges defined\n" if !$challenges;
|
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 ];
|
my $supported_types = $self->supported_challenge_types();
|
||||||
die "no $c_type challenge defined in authorization\n"
|
|
||||||
if ! scalar $tmp_challenges;
|
|
||||||
|
|
||||||
my $challenge = $tmp_challenges->[0];
|
# preference returned by plugin!
|
||||||
|
foreach my $supported_type (@$supported_types) {
|
||||||
|
foreach my $challenge (@$challenges) {
|
||||||
|
next if $challenge->{type} ne $supported_type;
|
||||||
|
|
||||||
return $challenge;
|
return $challenge;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
die "plugin does not support any of the requested challenge types\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_subplugins {
|
sub get_subplugins {
|
||||||
|
@ -11,7 +11,7 @@ use base qw(PVE::ACME::Challenge);
|
|||||||
my $ACME_PATH = '/usr/share/proxmox-acme/proxmox-acme';
|
my $ACME_PATH = '/usr/share/proxmox-acme/proxmox-acme';
|
||||||
|
|
||||||
sub supported_challenge_types {
|
sub supported_challenge_types {
|
||||||
return { 'dns-01' => 1 };
|
return ["dns-01"];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub type {
|
sub type {
|
||||||
@ -143,12 +143,6 @@ sub options {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub extract_challenge {
|
|
||||||
my ($self, $challenge) = @_;
|
|
||||||
|
|
||||||
return PVE::ACME::Challenge->extract_challenge($challenge, 'dns-01');
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_subplugins {
|
sub get_subplugins {
|
||||||
return $api_name_list;
|
return $api_name_list;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use HTTP::Response;
|
|||||||
use base qw(PVE::ACME::Challenge);
|
use base qw(PVE::ACME::Challenge);
|
||||||
|
|
||||||
sub supported_challenge_types {
|
sub supported_challenge_types {
|
||||||
return { 'http-01' => 1 };
|
return ['http-01'];
|
||||||
}
|
}
|
||||||
|
|
||||||
sub type {
|
sub type {
|
||||||
@ -27,12 +27,6 @@ sub options {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub extract_challenge {
|
|
||||||
my ($self, $challenge) = @_;
|
|
||||||
|
|
||||||
return PVE::ACME::Challenge->extract_challenge($challenge, 'http-01');
|
|
||||||
}
|
|
||||||
|
|
||||||
sub get_subplugins {
|
sub get_subplugins {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user