[pve-devel] [PATCH access-control 2/2] add ui capabilities endpoint

Tim Marx t.marx at proxmox.com
Wed May 6 14:00:54 CEST 2020


Signed-off-by: Tim Marx <t.marx at proxmox.com>
---
 PVE/API2/AccessControl.pm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/PVE/API2/AccessControl.pm b/PVE/API2/AccessControl.pm
index 25230ac..0a1b836 100644
--- a/PVE/API2/AccessControl.pm
+++ b/PVE/API2/AccessControl.pm
@@ -717,4 +717,33 @@ __PACKAGE__->register_method({
 	return $res;
     }});
 
+__PACKAGE__->register_method({
+    name => 'uicapabilities',
+    path => 'uicapabilities',
+    method => 'GET',
+    description => 'Retrieve user interface capabilities for calling user/token.',
+    permissions => {
+	description => "Each user/token is allowed to retrieve their own capabilities.",
+	user => 'all',
+    },
+    parameters => {},
+    returns => {
+	type => 'object',
+	properties => {
+	    cap => {
+		type => 'object',
+		description => 'The user interface capabilities of the calling user/token'
+	    }
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+	my $userid = $rpcenv->get_user();
+	my $res->{cap} = &$compute_api_permission($rpcenv, $userid);
+
+	return $res;
+    }});
+
 1;
-- 
2.20.1




More information about the pve-devel mailing list