]> git.proxmox.com Git - proxmox-acme.git/blame - src/PVE/ACME/Challenge.pm
plugins: refactor setup/teardown signatures
[proxmox-acme.git] / src / PVE / ACME / Challenge.pm
CommitLineData
5460050d
WL
1package PVE::ACME::Challenge;
2
3use strict;
4use warnings;
5
762af3b1
WL
6use PVE::JSONSchema qw(get_standard_option);
7
8use base qw(PVE::SectionConfig);
9
10my $defaultData = {
11 additionalProperties => 0,
12 propertyList => {
13 id => {
14 description => "ACME Plugin ID name",
15 type => 'string',
16 },
17 type => {
18 description => "ACME challenge type.",
19 type => 'string',
20 },
21 disable => {
22 description => "Flag to disable the config.",
23 type => 'boolean',
24 optional => 1,
25 },
26 nodes => get_standard_option('pve-node-list', { optional => 1 }),
27 },
28};
29
30sub private {
31 return $defaultData;
32}
33
c82603c9
FG
34sub parse_config {
35 my ($class, $filename, $raw) = @_;
36
37 my $cfg = $class->SUPER::parse_config($filename, $raw);
38 my $ids = $cfg->{ids};
39
40 # make sure we have a standalone plugin definition as fallback!
41 if (!$ids->{standalone} || $ids->{standalone}->{type} ne 'standalone') {
42 $ids->{standalone} = {
43 type => 'standalone',
44 };
45 }
46
47 return $cfg;
48}
49
5460050d
WL
50sub supported_challenge_types {
51 return {};
52}
53
762af3b1
WL
54sub extract_challenge {
55 my ($self, $challenges, $c_type) = @_;
56
57 die "no challenges defined\n" if !$challenges;
58 die "no challenge type is defined \n" if !$c_type;
59
60 my $tmp_challenges = [ grep {$_->{type} eq $c_type} @$challenges ];
61 die "no $c_type challenge defined in authorization\n"
62 if ! scalar $tmp_challenges;
63
64 my $challenge = $tmp_challenges->[0];
65
66 return $challenge;
67}
68
69sub get_subplugins {
70 return [];
71}
72
f00829fd
FG
73# acme => PVE::ACME instance
74# auth => authorization object returned by ACME server
75# $data => {
76# plugin => plugin config data
77# alias => optional domain alias
78# }
79# needs to set $data->{url} to URL of the challenge which has been set up
80# can set other $data keys needed by teardown sub
5460050d 81sub setup {
f00829fd 82 my ($self, $acme, $auth, $data) = @_;
5460050d
WL
83
84 die "implement me\n";
85}
86
f00829fd 87# see setup
5460050d 88sub teardown {
f00829fd 89 my ($self, $acme, $auth, $data) = @_;
5460050d
WL
90
91 die "implement me\n";
92}
93
941;