Commit Graph

16 Commits

Author SHA1 Message Date
Wolfgang Bumiller
3c4cebc9b7 api: include tfa lock status in user list
this means /access/users is now a 'protected' call to get
access to 'priv/tfa.cfg'

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 12:59:32 +02:00
Wolfgang Bumiller
330b8dbbe1 api: add /access/users/<userid>/unlock-tfa api call
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 12:59:32 +02:00
Fabian Grünbichler
59164ff16b api2: token: use userid-group as API perm check
the previous version using an ACL path of '/access/users/{userid}' was
broken for non-root users, since the '@' character always contained in a
userid is not allowed in ACL paths.

this effectively meant that creating API tokens only worked for:
- root@pam (ACL checks skipped altogether)
- users with User.Modify on '/' with propagation (the roles/privs for
  '/' are propagated to the undefined path in this case)
- users creating their own tokens (first branch of 'or')

the userid-group check is used for all other modifications of user
entities, so it can also be used for creating/modifying/removing API
tokens.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-20 15:47:03 +02:00
Wolfgang Bumiller
031e388f88 api: get user: declare token schema
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-03-21 16:08:21 +01:00
Fabian Grünbichler
aee071adf3 userid-group check: distinguish create and update
and check both existing groups and the groups parameter in the update
case. the following user.cfg settings can be used for testing:

user:test@pve:1:0:t:::
user:other@pve:1:0:t:::
group:test:test@pve::
group:test3:::
role:RealmUserAllocator:Realm.AllocateUser:
role:UserModifier:User.Modify:
acl:0:/access/groups/test:test@pve:UserModifier:
acl:0:/access/groups/test3:@test:UserModifier:
acl:0:/access/realm/pve:test@pve:RealmUserAllocator:

unchanged: the user 'test@pve' can allocate new '@pve' users, but
only if the created user will belong to at least one of 'test'
(direct ACL for that user) or 'test3' (indirect ACL via 'test' group)
groups.

changed: if the user 'test@pve' updates an existing user, they need
to (A) have 'User.Modify' on at least one existing group of that
user, and (B) 'User.Modify' on all of the groups passed in via the
'groups' parameter. A is the general rule for 'allowed to modify
user' across the board, but was missing for this specific variant of
the check. B was the case before, but just checking this without also
checking A allows a user to pull off-limits users into groups that
they can modify, which then in turn allows them to modify those users
via A which is now passing.

for example, without this patch 'test@pve' would be able to add
'other@pve' to either 'test' or 'test3', and then in turn call any of
the API endpoints that require 'User.Modify' on a user's group
(change TFA, change password or delete user if realm is pve, ..).

all the other userid-group checks without group_param set remain
unchanged as well, since $check_existing_user is true in that case.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-21 11:03:14 +01:00
Wolfgang Bumiller
d168ab34d6 update tfa cleanup when deleting users
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-10 11:13:21 +01:00
Wolfgang Bumiller
f7f2e28e6d update read_user_tfa_type call
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-10 11:13:21 +01:00
Thomas Lamprecht
e780b46aab api: delete user: better communicate partial deletion
this is really an edge case and should not happen often in practice,
the time window is small and deletions are not _that_ common, but
still.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-27 15:48:21 +02:00
Thomas Lamprecht
ba6cc98fcb api: delete user: disable first to avoid surprise on error
Write out a config with the user disabled so that it cannot be used
even if deletion fails, why ever that is

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-27 15:47:22 +02:00
Thomas Lamprecht
8ecf1a490d fix #2302: allow deletion of users when realm enforces TFA
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-27 15:32:05 +02:00
Thomas Lamprecht
3e5b237feb api: user: indentation & whitspace cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-23 14:16:50 +02:00
Thomas Lamprecht
d658d04acb api: users: use public regex directly to parse out realm
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 13:42:16 +02:00
Thomas Lamprecht
525a931b98 api: users: code-style cleanup and sort when iterating users
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 13:41:29 +02:00
Thomas Lamprecht
3f6023f55c api: users: s/realmtype/realm-type/ in response
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-02 13:38:46 +02:00
Dominik Csapak
8bb59c2612 api: user: add realmtype to user list
this makes it much easier to determine if a user can e.g.
change a password or tfa, based on realm

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2021-07-02 13:14:51 +02:00
Thomas Lamprecht
197d1016fd buildsys: split packaging and source build-systems
Much nicer to handle and work with than entangling all together in a
single spaghetti pile.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-05-09 19:48:50 +02:00