5
0
mirror of git://git.proxmox.com/git/pve-access-control.git synced 2025-01-06 13:17:54 +03:00
Commit Graph

611 Commits

Author SHA1 Message Date
Fabian Grünbichler
37d3c16b25 perm check: forbid undefined/empty ACL path
to detect similar issues to that fixed in the previous commit early on
and without the potential for dangerous side-effects.

root@pam is intentionally still allowed before the check in case such
situations can be triggered by misconfiguration - root@pam can then
still clean up the affected configs via the GUI/API, and not just via
manual editing.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-20 15:47:03 +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
Thomas Lamprecht
1cf4389b42 bump version to 7.2-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-06-03 14:02:35 +02:00
Thomas Lamprecht
0fd902ce54 README: break long lines
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-06-03 13:58:46 +02:00
Thomas Lamprecht
7d23b7cac8 tree wide: typo fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-06-03 13:58:07 +02:00
Fabian Grünbichler
b8c4218b97 permissions: add some more comments
for future reference/changes.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-03 13:53:02 +02:00
Fabian Grünbichler
0716a56be3 permissions: fix token/user priv intersection
the token/user priv intersection could only honored user privs that had
the propagation flag set, reducing the scope of the token more than
intended.

the pre-existing test case actually triggered the broken behaviour, but
the expected value matched it so it was not noticed.

Fixes: e8a0cee47b "rpcenv: improve user/token intersection"

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-03 13:53:02 +02:00
Fabian Grünbichler
b55e33f4e4 permissions: properly merge propagation flag
when multiple roles are defined on a path that share a privilege, this
randomly took the propagation flag for the priv from the last role
encountered. since perl hashes are iterated randomly, this means the
propagation flag was sometimes set correctly, and sometimes not.

note that this propagation flag is only used for display/dumping
purposes, and for intersection with token privs (see next commit).
actual handling of propagation happens on the role level in
PVE::AccessControl::roles().

modified test case (spuriously) fails without the fix.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-06-03 13:53:02 +02:00
Thomas Lamprecht
e3604d4827 bump version to 7.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-31 13:43:47 +02:00
Thomas Lamprecht
aaacf4c311 access check: include user/token id in expired exception
not that relevant for the user as the daemon auth log already
contains that info, but for token it can be nice.

The API response is always just a plain "401 auth failure" in any
case (expired or wrong creds)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-31 13:37:51 +02:00
Thomas Lamprecht
5ff516de53 check user: re-order enable check first again and adhere noerr flag
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-31 13:31:23 +02:00
Oguz Bektas
d0cce79f8b user check: fix expiration/enable order
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-05-31 13:22:17 +02:00
Thomas Lamprecht
79ae250ff9 bump version to 7.1-8
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-28 17:02:54 +02:00
Dominik Csapak
fa2afa15b2 add realm-sync regression test for new 'remove-vanished'
by having a test case that does not delete properties, but acls and
entries

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-26 13:06:23 +02:00
Dominik Csapak
2f58f6715e convert regression tests to new 'remove-vanished' parameter
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-26 13:06:23 +02:00
Dominik Csapak
98df2ebc53 fix #3668: realm-sync: replace 'full' & 'purge' with 'remove-vanished'
Both, 'full' & 'purge', configure what is removed when an entry
(or property) is not returned anymore from the sync result. For users
it may be thus easier to understand setting a single property without
wondering about the interaction of the two specific ones.

The new 'remove-vanished' is a list of things to remove, namely:
 * 'acl'
 * 'entry'
 * 'properties'.

The old 'full' gets mapped to 'entry;properties' and an old 'purge'
to the 'acl'

Keep the old properties for backwards-compatibility but transform to
the new list on edit. Add a deprecation notice to the description
with a TODO reminder to remove with 8.0

Note, this commit changes two things slightly:
* 'purge' (now remove-vanished -> acl) does now remove ACLs for
  vanished entries even when we keep those entries. Previously those
  were only deleted when we also removed the entries (this can be
  seen by the changed regression test)
* since 'remove-vanished' is empty by default, only the scope must be
  given explicitly on sync or the sync-default. Previously 'full' and
  'purge' must have been configured explicitly (no big deal, since
  the default is to not remove anything)

Bug #3668 is fixed when not selecting 'properties' for the sync, so
that existing (custom) properties are not deleted on update

Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[ T: some commit message typos/wording ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-26 13:00:26 +02:00
Dominik Csapak
dcdf57891b add regression tests for realm-sync
to fully test the 'end-to-end' sync api call, we have to mock quite
some methods for cluster/rpcenvironment/ldap

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-04-26 13:00:26 +02:00
Thomas Lamprecht
c870b202e4 rpc env: indentation fixes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-23 12:24:57 +01:00
Thomas Lamprecht
eed462861b bump version to 7.1-7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-03-21 16:15:29 +01: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
Fabian Grünbichler
cd78b2958f bump version to 7.1-6
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-01-21 14:21:04 +01:00
Fabian Grünbichler
9aa49a8de1 rpcenv->permissions() ensure propagate is always defined
this shouldn't happen anymore, but a safeguard in case the parser ever
has a bug does not hurt.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-01-21 14:21:04 +01:00
Fabian Grünbichler
0786c1e5df rpcenv: skip undef propagation flag in more places
these are just cosmetic fixes/safeguards against future bugs -
compute_api_permissions is used to set the 'cap' object to hide parts of
the GUI that are not usable without the corresponding privs in the
backend anyway, and get_effective_permissions is only used to return the
permission tree without a specific path query.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-01-21 14:21:04 +01:00
Fabian Grünbichler
1bd10ecfa9 test: extend intersection tests
to check the previous commit's fix.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-01-21 14:21:04 +01:00
Fabian Grünbichler
e8a0cee47b rpcenv: improve user/token intersection
this could return undef for the propagation flag instead of 1/0, leading
to confusing displays of permission trees. all the actual checks using
the returned hash check for definedness anyway, so the actual
privileges checked and the displayed ones were not identical.

fixes: 7e8bcaa754
"roles()/permissions(): also return propagate flag"

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-01-21 14:21:04 +01:00
Thomas Lamprecht
92f571d9ff get effective permissions: return /sdn path too
only cosmetic for the user to see what their permission tree looks
like.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-01-21 14:19:57 +01:00
Wolfgang Bumiller
0c50321183 fix realm sync permissions
The userid-* permission check variants work on
$param->{userid} directly which does not exist for this
call. Also, they work on the realm of the user being
checked, rather than the realm provided as parameter.

The result was that as non-root user this always failed
with the message "userid '' too short"

Fix this by making the check explicitly work like in the
description.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-12-20 20:18:41 +01:00
Wolfgang Bumiller
2974aa3345 use statement fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-14 09:13:44 +01:00
Wolfgang Bumiller
dc7ef2401a tfa list: account for admin permissions
instead of restricting listing tfa entries of others to
root@pam, perform the same checks the user-list does and
which also reflect the permissions of the api calls actually
operating on those users, so, `User.Modify` on the user (but
also `Sys.Audit`, since it's only a read-operation, just
like the user index API call)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-07 09:08:01 +01:00
Wolfgang Bumiller
dd9e95b187 tfa: when modifying others, verify the current user's password
this was wrong as it asked for the password of the
to-be-edited user instead, which makes no sense

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-07 09:08:01 +01:00
Wolfgang Bumiller
280d0edd2c fix #3768: warn on bad u2f or webauthn settings
but don't bail out of the entire auth process, otherwise
not even totp or recovery keys will work anymore in this
case

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-06 13:55:14 +01:00
Wolfgang Bumiller
7262f24391 fix a 'use of undefined...' warning
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-06 13:55:14 +01:00
Thomas Lamprecht
118088d89e bump version to 7.1-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-25 07:59:21 +01:00
Thomas Lamprecht
aa71c0f0f6 openid: fix username-claim fallback
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-25 07:58:48 +01:00
Wolfgang Bumiller
ebb14277f1 bump version to 7.1-4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-22 14:04:57 +01:00
Wolfgang Bumiller
d12f247edc fill origin into webauthn config if not provided
in order to allow subdomains to work, the wa config should
only specify 'id' and 'rp', the 'origin' gets filled in by
the node

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-22 13:55:21 +01:00
Thomas Lamprecht
44a55ff792 bump version to 7.1-3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-19 14:35:44 +01:00
Thomas Lamprecht
8a47ffa50b d/control: bump versioned dependency to libpve-rs-perl
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-19 14:35:44 +01:00
Thomas Lamprecht
bc9d11591e openid: support configuring ACR values
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-19 06:59:34 +01:00
Thomas Lamprecht
48e51c3383 openid: support configuring scopes
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-18 17:00:42 +01:00
Thomas Lamprecht
348c703875 openid: support configuring the prompt
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-18 16:30:41 +01:00
Thomas Lamprecht
83f0ad5d8d openid: fix whitespace/indentation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-18 14:52:52 +01:00
Thomas Lamprecht
271bbc10e9 openid: allow arbitrary username-claims
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-18 14:31:08 +01:00
Thomas Lamprecht
6f643e7953 bump version to 7.1-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-17 13:48:24 +01:00
Thomas Lamprecht
dbbd91c27f d/control: bump versioned dependency to libpve-rs-perl
to ensure we get the incompatible type set for such TFA entries

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-17 13:48:24 +01:00
Wolfgang Bumiller
93c1d74a62 catch incompatible tfa entries with a nice error
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-17 12:52:56 +01:00
Thomas Lamprecht
92bca71e86 bump version to 7.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-15 15:33:29 +01:00
Wolfgang Bumiller
b3dae5dd48 tfa: fix http 404 in get_tfa_entry
this produced warnings in the journal and returned code 500
instead

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-12 11:01:48 +01:00
Thomas Lamprecht
1c9b650186 bump version to 7.0-7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-11 18:20:02 +01:00