fix #1998: correct return properties for read_role

we have each privilege as property of the return object,
so we generate it from $valid_privs

this has the advantage that all privileges are well documented
with that api call

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-11-23 14:11:51 +01:00 committed by Thomas Lamprecht
parent b54b7474bb
commit 0fea3f1677
2 changed files with 12 additions and 3 deletions

View File

@ -163,9 +163,7 @@ __PACKAGE__->register_method ({
returns => { returns => {
type => "object", type => "object",
additionalProperties => 0, additionalProperties => 0,
properties => { properties => PVE::AccessControl::create_priv_properties(),
privs => get_standard_option('role-privs'),
},
}, },
code => sub { code => sub {
my ($param) = @_; my ($param) = @_;

View File

@ -499,6 +499,17 @@ sub create_roles {
create_roles(); create_roles();
sub create_priv_properties {
my $properties = {};
foreach my $priv (keys %$valid_privs) {
$properties->{$priv} = {
type => 'boolean',
optional => 1,
};
}
return $properties;
}
sub role_is_special { sub role_is_special {
my ($role) = @_; my ($role) = @_;
return (exists $special_roles->{$role}) ? 1 : 0; return (exists $special_roles->{$role}) ? 1 : 0;