]>
Commit | Line | Data |
---|---|---|
5460050d WL |
1 | package PVE::ACME::Challenge; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
762af3b1 WL |
6 | use PVE::JSONSchema qw(get_standard_option); |
7 | ||
8 | use base qw(PVE::SectionConfig); | |
9 | ||
10 | my $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 | ||
30 | sub private { | |
31 | return $defaultData; | |
32 | } | |
33 | ||
c82603c9 FG |
34 | sub 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 | 50 | sub supported_challenge_types { |
122626b3 | 51 | return []; |
5460050d WL |
52 | } |
53 | ||
762af3b1 | 54 | sub extract_challenge { |
122626b3 | 55 | my ($self, $challenges) = @_; |
762af3b1 WL |
56 | |
57 | die "no challenges defined\n" if !$challenges; | |
762af3b1 | 58 | |
122626b3 FG |
59 | my $supported_types = $self->supported_challenge_types(); |
60 | ||
61 | # preference returned by plugin! | |
62 | foreach my $supported_type (@$supported_types) { | |
63 | foreach my $challenge (@$challenges) { | |
64 | next if $challenge->{type} ne $supported_type; | |
762af3b1 | 65 | |
122626b3 FG |
66 | return $challenge; |
67 | } | |
68 | } | |
762af3b1 | 69 | |
122626b3 | 70 | die "plugin does not support any of the requested challenge types\n"; |
762af3b1 WL |
71 | } |
72 | ||
73 | sub get_subplugins { | |
74 | return []; | |
75 | } | |
76 | ||
f00829fd FG |
77 | # acme => PVE::ACME instance |
78 | # auth => authorization object returned by ACME server | |
79 | # $data => { | |
80 | # plugin => plugin config data | |
81 | # alias => optional domain alias | |
82 | # } | |
83 | # needs to set $data->{url} to URL of the challenge which has been set up | |
84 | # can set other $data keys needed by teardown sub | |
5460050d | 85 | sub setup { |
f00829fd | 86 | my ($self, $acme, $auth, $data) = @_; |
5460050d WL |
87 | |
88 | die "implement me\n"; | |
89 | } | |
90 | ||
f00829fd | 91 | # see setup |
5460050d | 92 | sub teardown { |
f00829fd | 93 | my ($self, $acme, $auth, $data) = @_; |
5460050d WL |
94 | |
95 | die "implement me\n"; | |
96 | } | |
97 | ||
98 | 1; |