API schema: add 'allowtoken' property

to mark which API methods should be available to clients authenticated using an API token.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-01-21 13:53:56 +01:00 committed by Thomas Lamprecht
parent f82c73738d
commit 4c72ade059
2 changed files with 9 additions and 0 deletions

View File

@ -1294,6 +1294,12 @@ my $method_schema = {
description => "Method needs special privileges - only pvedaemon can execute it", description => "Method needs special privileges - only pvedaemon can execute it",
optional => 1, optional => 1,
}, },
allowtoken => {
type => 'boolean',
description => "Method is available for clients authenticated using an API token.",
optional => 1,
default => 1,
},
download => { download => {
type => 'boolean', type => 'boolean',
description => "Method downloads the file content (filename is the return value of the method).", description => "Method downloads the file content (filename is the return value of the method).",

View File

@ -242,6 +242,9 @@ sub register_method {
$errprefix = "register method ${self}/$info->{path} -"; $errprefix = "register method ${self}/$info->{path} -";
$info->{method} = 'GET' if !$info->{method}; $info->{method} = 'GET' if !$info->{method};
$method = $info->{method}; $method = $info->{method};
# apply default value
$info->{allowtoken} = 1 if !defined($info->{allowtoken});
} }
$method_path_lookup->{$self} = {} if !defined($method_path_lookup->{$self}); $method_path_lookup->{$self} = {} if !defined($method_path_lookup->{$self});