From 4c72ade059c8af6ae94158377b36fb8e6eb9672b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Tue, 21 Jan 2020 13:53:56 +0100 Subject: [PATCH] API schema: add 'allowtoken' property MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit to mark which API methods should be available to clients authenticated using an API token. Signed-off-by: Fabian Grünbichler --- src/PVE/JSONSchema.pm | 6 ++++++ src/PVE/RESTHandler.pm | 3 +++ 2 files changed, 9 insertions(+) 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}); -- 2.39.2