]> git.proxmox.com Git - pve-access-control.git/blobdiff - PVE/API2/User.pm
Whitespace fixes
[pve-access-control.git] / PVE / API2 / User.pm
index 602e3f030ba4bc990adf7717e659f1007cf1b7f5..1dc0293287a03829f8ea0812e12dbec8963c2a26 100644 (file)
@@ -31,11 +31,11 @@ my $extract_user_data = sub {
 };
 
 __PACKAGE__->register_method ({
-    name => 'index', 
-    path => '', 
+    name => 'index',
+    path => '',
     method => 'GET',
     description => "User index.",
-    permissions => { 
+    permissions => {
        description => "The returned list is restricted to users where you have 'User.Modify' or 'Sys.Audit' permissions on '/access/groups' or on a group the user belongs too. But it always includes the current (authenticated) user.",
        user => 'all',
     },
@@ -61,7 +61,7 @@ __PACKAGE__->register_method ({
     },
     code => sub {
        my ($param) = @_;
-    
+
        my $rpcenv = PVE::RPCEnvironment::get();
        my $usercfg = $rpcenv->{user_cfg};
        my $authuser = $rpcenv->get_user();
@@ -71,7 +71,7 @@ __PACKAGE__->register_method ({
        my $privs = [ 'User.Modify', 'Sys.Audit' ];
        my $canUserMod = $rpcenv->check_any($authuser, "/access/groups", $privs, 1);
        my $groups = $rpcenv->filter_groups($authuser, $privs, 1);
-       my $allowed_users = $rpcenv->group_member_join([keys %$groups]);      
+       my $allowed_users = $rpcenv->group_member_join([keys %$groups]);
 
        foreach my $user (keys %{$usercfg->{users}}) {
 
@@ -94,11 +94,11 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'create_user', 
+    name => 'create_user',
     protected => 1,
-    path => '', 
+    path => '',
     method => 'POST',
-    permissions => { 
+    permissions => {
        description => "You need 'Realm.AllocateUser' on '/access/realm/<realm>' on the realm of user <userid>, and 'User.Modify' permissions to '/access/groups/<group>' for any group specified (or 'User.Modify' on '/access/groups' if you pass no groups.",
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
@@ -107,15 +107,15 @@ __PACKAGE__->register_method ({
     },
     description => "Create new user.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid'),
            password => {
                description => "Initial password.",
-               type => 'string', 
-               optional => 1, 
-               minLength => 5, 
-               maxLength => 64 
+               type => 'string',
+               optional => 1,
+               minLength => 5,
+               maxLength => 64
            },
            groups => {
                type => 'string', format => 'pve-groupid-list',
@@ -128,12 +128,12 @@ __PACKAGE__->register_method ({
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
-               type => 'string', 
+               type => 'string',
                optional => 1,
            },
-           expire => { 
+           expire => {
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
-               type => 'integer', 
+               type => 'integer',
                minimum => 0,
                optional => 1,
            },
@@ -151,14 +151,14 @@ __PACKAGE__->register_method ({
 
        PVE::AccessControl::lock_user_config(
            sub {
-                       
+
                my ($username, $ruid, $realm) = PVE::AccessControl::verify_username($param->{userid});
-       
+
                my $usercfg = cfs_read_file("user.cfg");
 
-               die "user '$username' already exists\n" 
+               die "user '$username' already exists\n"
                    if $usercfg->{users}->{$username};
-                        
+
                PVE::AccessControl::domain_set_password($realm, $ruid, $param->{password})
                    if defined($param->{password});
 
@@ -189,56 +189,56 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'read_user', 
-    path => '{userid}', 
+    name => 'read_user',
+    path => '{userid}',
     method => 'GET',
     description => "Get user configuration.",
-    permissions => { 
+    permissions => {
        check => ['userid-group', ['User.Modify', 'Sys.Audit']],
     },
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid'),
        },
     },
     returns => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            enable => { type => 'boolean' },
            expire => { type => 'integer', optional => 1 },
            firstname => { type => 'string', optional => 1 },
            lastname => { type => 'string', optional => 1 },
            email => { type => 'string', optional => 1 },
-           comment => { type => 'string', optional => 1 },    
-           keys => { type => 'string', optional => 1 },    
+           comment => { type => 'string', optional => 1 },
+           keys => { type => 'string', optional => 1 },
            groups => { type => 'array' },
        }
     },
     code => sub {
        my ($param) = @_;
 
-       my ($username, undef, $domain) = 
+       my ($username, undef, $domain) =
            PVE::AccessControl::verify_username($param->{userid});
 
        my $usercfg = cfs_read_file("user.cfg");
 
        my $data = PVE::AccessControl::check_user_exist($usercfg, $username);
+
        return &$extract_user_data($data, 1);
     }});
 
 __PACKAGE__->register_method ({
-    name => 'update_user', 
+    name => 'update_user',
     protected => 1,
-    path => '{userid}', 
+    path => '{userid}',
     method => 'PUT',
-    permissions => { 
+    permissions => {
        check => ['userid-group', ['User.Modify'], groups_param => 1 ],
     },
     description => "Update user configuration.",
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
@@ -248,8 +248,8 @@ __PACKAGE__->register_method ({
                optional => 1,
                completion => \&PVE::AccessControl::complete_group,
            },
-           append => { 
-               type => 'boolean', 
+           append => {
+               type => 'boolean',
                optional => 1,
                requires => 'groups',
            },
@@ -264,14 +264,14 @@ __PACKAGE__->register_method ({
            comment => { type => 'string', optional => 1 },
            keys => {
                description => "Keys for two factor auth (yubico).",
-               type => 'string', 
+               type => 'string',
                optional => 1,
            },
-           expire => { 
+           expire => {
                description => "Account expiration date (seconds since epoch). '0' means no expiration date.",
-               type => 'integer', 
+               type => 'integer',
                minimum => 0,
-               optional => 1 
+               optional => 1
            },
        },
     },
@@ -279,12 +279,12 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       my ($username, $ruid, $realm) = 
+       my ($username, $ruid, $realm) =
            PVE::AccessControl::verify_username($param->{userid});
-       
+
        PVE::AccessControl::lock_user_config(
            sub {
-       
+
                my $usercfg = cfs_read_file("user.cfg");
 
                PVE::AccessControl::check_user_exist($usercfg, $username);
@@ -293,7 +293,7 @@ __PACKAGE__->register_method ({
 
                $usercfg->{users}->{$username}->{expire} = $param->{expire} if defined($param->{expire});
 
-               PVE::AccessControl::delete_user_group($username, $usercfg) 
+               PVE::AccessControl::delete_user_group($username, $usercfg)
                    if (!$param->{append} && defined($param->{groups}));
 
                if ($param->{groups}) {
@@ -314,24 +314,24 @@ __PACKAGE__->register_method ({
 
                cfs_write_file("user.cfg", $usercfg);
            }, "update user failed");
-       
+
        return undef;
     }});
 
 __PACKAGE__->register_method ({
-    name => 'delete_user', 
+    name => 'delete_user',
     protected => 1,
-    path => '{userid}', 
+    path => '{userid}',
     method => 'DELETE',
     description => "Delete user.",
-    permissions => { 
+    permissions => {
        check => [ 'and',
                   [ 'userid-param', 'Realm.AllocateUser'],
                   [ 'userid-group', ['User.Modify']],
            ],
     },
     parameters => {
-       additionalProperties => 0,
+       additionalProperties => 0,
        properties => {
            userid => get_standard_option('userid', {
                completion => \&PVE::AccessControl::complete_username,
@@ -341,11 +341,11 @@ __PACKAGE__->register_method ({
     returns => { type => 'null' },
     code => sub {
        my ($param) = @_;
-       
+
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
-       my ($userid, $ruid, $realm) = 
+       my ($userid, $ruid, $realm) =
            PVE::AccessControl::verify_username($param->{userid});
 
        PVE::AccessControl::lock_user_config(
@@ -366,7 +366,7 @@ __PACKAGE__->register_method ({
 
                cfs_write_file("user.cfg", $usercfg);
            }, "delete user failed");
-       
+
        return undef;
     }});