mirror of
https://git.proxmox.com/git/pve-access-control
synced 2025-07-23 22:29:03 +00:00
pveum: implement bash completion hooks
This commit is contained in:
parent
e69dbe105d
commit
3e5bfdf60f
@ -235,10 +235,13 @@ __PACKAGE__->register_method ({
|
|||||||
description => "User name",
|
description => "User name",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
maxLength => 64,
|
maxLength => 64,
|
||||||
|
completion => \&PVE::AccessControl::complete_username,
|
||||||
},
|
},
|
||||||
realm => get_standard_option('realm', {
|
realm => get_standard_option('realm', {
|
||||||
description => "You can optionally pass the realm using this parameter. Normally the realm is simply added to the username <username>\@<relam>.",
|
description => "You can optionally pass the realm using this parameter. Normally the realm is simply added to the username <username>\@<relam>.",
|
||||||
optional => 1}),
|
optional => 1,
|
||||||
|
completion => \&PVE::AccessControl::complete_realm,
|
||||||
|
}),
|
||||||
password => {
|
password => {
|
||||||
description => "The secret password. This can also be a valid ticket.",
|
description => "The secret password. This can also be a valid ticket.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
@ -325,7 +328,9 @@ __PACKAGE__->register_method ({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
userid => get_standard_option('userid'),
|
userid => get_standard_option('userid', {
|
||||||
|
completion => \&PVE::AccessControl::complete_username,
|
||||||
|
}),
|
||||||
password => {
|
password => {
|
||||||
description => "The new password.",
|
description => "The new password.",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
|
@ -107,7 +107,10 @@ __PACKAGE__->register_method ({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
groupid => { type => 'string', format => 'pve-groupid' },
|
groupid => {
|
||||||
|
type => 'string', format => 'pve-groupid',
|
||||||
|
completion => \&PVE::AccessControl::complete_group,
|
||||||
|
},
|
||||||
comment => { type => 'string', optional => 1 },
|
comment => { type => 'string', optional => 1 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -195,7 +198,10 @@ __PACKAGE__->register_method ({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
groupid => { type => 'string' , format => 'pve-groupid' },
|
groupid => {
|
||||||
|
type => 'string' , format => 'pve-groupid',
|
||||||
|
completion => \&PVE::AccessControl::complete_group,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
returns => { type => 'null' },
|
returns => { type => 'null' },
|
||||||
|
@ -119,7 +119,11 @@ __PACKAGE__->register_method ({
|
|||||||
minLength => 5,
|
minLength => 5,
|
||||||
maxLength => 64
|
maxLength => 64
|
||||||
},
|
},
|
||||||
groups => { type => 'string', optional => 1, format => 'pve-groupid-list'},
|
groups => {
|
||||||
|
type => 'string', format => 'pve-groupid-list',
|
||||||
|
optional => 1,
|
||||||
|
completion => \&PVE::AccessControl::complete_group,
|
||||||
|
},
|
||||||
firstname => { type => 'string', optional => 1 },
|
firstname => { type => 'string', optional => 1 },
|
||||||
lastname => { type => 'string', optional => 1 },
|
lastname => { type => 'string', optional => 1 },
|
||||||
email => { type => 'string', optional => 1, format => 'email-opt' },
|
email => { type => 'string', optional => 1, format => 'email-opt' },
|
||||||
@ -238,8 +242,14 @@ __PACKAGE__->register_method ({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
userid => get_standard_option('userid'),
|
userid => get_standard_option('userid', {
|
||||||
groups => { type => 'string', optional => 1, format => 'pve-groupid-list' },
|
completion => \&PVE::AccessControl::complete_username,
|
||||||
|
}),
|
||||||
|
groups => {
|
||||||
|
type => 'string', format => 'pve-groupid-list',
|
||||||
|
optional => 1,
|
||||||
|
completion => \&PVE::AccessControl::complete_group,
|
||||||
|
},
|
||||||
append => {
|
append => {
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
optional => 1,
|
optional => 1,
|
||||||
@ -325,7 +335,9 @@ __PACKAGE__->register_method ({
|
|||||||
parameters => {
|
parameters => {
|
||||||
additionalProperties => 0,
|
additionalProperties => 0,
|
||||||
properties => {
|
properties => {
|
||||||
userid => get_standard_option('userid'),
|
userid => get_standard_option('userid', {
|
||||||
|
completion => \&PVE::AccessControl::complete_username,
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
returns => { type => 'null' },
|
returns => { type => 'null' },
|
||||||
|
@ -1294,4 +1294,27 @@ sub oath_verify_otp {
|
|||||||
die "oath auth failed\n" if !$found;
|
die "oath auth failed\n" if !$found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# bash completion helpers
|
||||||
|
|
||||||
|
sub complete_username {
|
||||||
|
|
||||||
|
my $user_cfg = cfs_read_file('user.cfg');
|
||||||
|
|
||||||
|
return [ keys %{$user_cfg->{users}} ];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub complete_group {
|
||||||
|
|
||||||
|
my $user_cfg = cfs_read_file('user.cfg');
|
||||||
|
|
||||||
|
return [ keys %{$user_cfg->{groups}} ];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub complete_realm {
|
||||||
|
|
||||||
|
my $domain_cfg = cfs_read_file('domains.cfg');
|
||||||
|
|
||||||
|
return [ keys %{$domain_cfg->{ids}} ];
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user