[pve-devel] applied: [PATCH v3 common 1/1] API schema: add 'allowtoken' property

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jan 27 18:39:47 CET 2020


On 1/21/20 1:53 PM, Fabian Grünbichler wrote:
> to mark which API methods should be available to clients authenticated using an API token.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
> ---
> 
> Notes:
>     any users of this need corresponding versioned depends.
>     
>     v2->v3:
>     - rename from notoken to allowtoken, negate semantics/default value accordingly
> 
>  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});
> 

applied, thanks!





More information about the pve-devel mailing list