From: Fabian Grünbichler Date: Tue, 21 Jan 2020 12:53:56 +0000 (+0100) Subject: API schema: add 'allowtoken' property X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=commitdiff_plain;h=4c72ade059c8af6ae94158377b36fb8e6eb9672b 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 --- diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm index 51c3881..599dd09 100644 --- a/src/PVE/JSONSchema.pm +++ b/src/PVE/JSONSchema.pm @@ -1294,6 +1294,12 @@ my $method_schema = { description => "Method needs special privileges - only pvedaemon can execute it", optional => 1, }, + allowtoken => { + type => 'boolean', + description => "Method is available for clients authenticated using an API token.", + optional => 1, + default => 1, + }, download => { type => 'boolean', description => "Method downloads the file content (filename is the return value of the method).", diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm index 5e8278e..299bf68 100644 --- a/src/PVE/RESTHandler.pm +++ b/src/PVE/RESTHandler.pm @@ -242,6 +242,9 @@ sub register_method { $errprefix = "register method ${self}/$info->{path} -"; $info->{method} = 'GET' if !$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});