Commit Graph

115 Commits

Author SHA1 Message Date
Thomas Lamprecht
91c30089a7 acl: check path: spell param out
we normally use shift only in closures, to keep them short, as a
module method this should rather use our standard style.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-04-19 11:48:52 +02:00
Lorenz Stechauner
20c60513b2 fix #1500: permission path syntax check for access control
Syntax for permission paths is now checked on API calls for
creation or update on permissions.

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
2021-04-19 10:13:45 +02:00
Thomas Lamprecht
f335d265b8 api/users: catch existing user also on case insensitive realm
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-09-29 08:51:36 +02:00
Wolfgang Link
eb41d20051 fix #2947 login name for the LDAP/AD realm can be case-insensitive
This is an optional for LDAP and AD realm.
The default behavior is case-sensitive.

Signed-off-by: Wolfgang Link <w.link@proxmox.com>
2020-09-29 06:14:53 +02:00
Thomas Lamprecht
9de25de807 partially fix #2825: authkey: rotate if it was generated in the future
Can happen if the RTC is in the future during installation and first
boot, when during key generation the clock is in the future and then,
after the key was already generated, jumps back in time.

Allow a fuzz of $auth_graceperiod, which is currently 5 minutes, as
that fuzz allows some minor, not really problematic, time sync
disparity in clusters.

If an old authkey exists, meaning we rotated at least once, check it's
time too. Only rotate if it'd not be valid for any tickets in the
cluster anymore, i.e., if it difference between the current key is >
$ticket_lifetime (2 hours)..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-04 18:22:51 +02:00
Thomas Lamprecht
8304b226d6 authkey: use variable instead of hard coded grace period value
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2020-07-03 15:18:45 +02:00
Mira Limbeck
cb381abc6b introduce VM.Config.Cloudinit permission
It is added to PVEVMUser by default.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2020-06-26 09:39:54 +02:00
Dominik Csapak
5654260eab do not modify ACLs/Groups for missing users
instead of dropping ACLs and group membership for missing users,
simply warn and leave it in the config

for users that get removed via the api this happens explicitely

this is to prevent that a 'faulty' ldapsync removes users temporarily
and with it all acls that the admin created

we still have a 'purge' flag for the sync where ACLs get removed
explicitly for users removed from ldap

also adapt the tests

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-03-21 16:05:38 +01:00
Fabian Grünbichler
21f523a5c1 user.cfg: skip inexisting roles when parsing ACLs
we do the same for missing users, groups and tokens, and just like
groups, roles with an empty privilege set are explicitly allowed so
pre-generating placeholders is possible.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:59 +01:00
Fabian Grünbichler
7e8bcaa754 roles()/permissions(): also return propagate flag
this information is already available, but not exposed. we need it for
dumping an effective permission tree of a given user/token.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
e915e9e454 API token: implement permission checks
non-privsep tokens will always return the roles/permissions of their
associated users. privsep tokens will return unfiltered roles, but
filtered permissions.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-29 21:21:58 +01:00
Fabian Grünbichler
35c3ca0fc8 API token: add verification method
which checks that the user and token exist and are not expired, and then
generates the string to be matched with the pmxcfs-stored token shadow
config file.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:49 +01:00
Fabian Grünbichler
571e9d062e API token: add check_token_exist API helper
the helper is modeled after the corresponding user method.

the 'tokenid' option goes into PVE::AccessControl, since we need it in
multiple API modules.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:40 +01:00
Fabian Grünbichler
28e3dc05e2 API token: add REs, helpers, parsing + writing
token definitions/references in user.cfg always use the full form of the
token id, consisting of:

USER@REALM!TOKENID

token definitions are represented by their own lines prefixed with
'token', which need to come after the corresponding user definition, but
before any ACLs referencing them.

parsed representation in a user config hash is inside a new 'tokens'
element of the corresponding user object, using the unique-per-user
token id as key.

only token metadata is stored inside user.cfg / accessible via the
parsed user config hash. the actual token values will be stored
root-readable only in a separate (shadow) file.

'comment' and 'expire' have the same semantics as for users.

'privsep' determines whether an API token gets the full privileges of
the corresponding user, or just the intersection of privileges of the
corresponding user and those of the API token itself.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-28 20:59:36 +01:00
Fabian Grünbichler
1516bfa0a6 fix typo
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-27 18:33:50 +01:00
Fabian Grünbichler
9a12a08ce9 refactor acl transformation code
pull it into helper sub, since we need this one more time for token ACL
members.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-14 12:28:46 +01:00
Fabian Grünbichler
a31f1d85f9 rpcenv: drop unused roles()
it was useful for test-cases to verify the behaviour when pools where
introduced, but it is not used anywhere else in the code base and those
tests can also just check on permission-level.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-14 12:24:04 +01:00
Thomas Lamprecht
3443faca75 grammar fix: s/does not exists/does not exist/g
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-12-13 12:01:22 +01:00
Alexandre Derumier
406726718e add SDN.Allocate && SDN.Audit privileges
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2019-11-26 16:49:47 +01:00
Fabian Grünbichler
9efcb56129 access-control: remove check_permissions/permission
they have been handled by PVE::RPCEnvironment for quite some time
already, and the versions there are the complete ones that should be
actually used.

manager switched over their last use not long ago, in 6.0-9, so
record a Breaks to that version.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-23 18:12:50 +01:00
Fabian Grünbichler
a5ec58ea9a user.cfg: sort group and pool members, role privs
makes no functional difference, but keeps the output/written config more
stable.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-23 17:41:04 +01:00
Fabian Grünbichler
733371da86 user.cfg: ensure propagate flag is 1/0 when parsing
otherwise this might end up as (arbitrary) string somewhere..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-11-23 17:33:37 +01:00
Fabian Grünbichler
9b3ae1efe3 user.cfg: sort ACL members
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-10-17 16:19:59 +02:00
Fabian Grünbichler
93c7e9c3d0 user.cfg: sort entries alphabetically in each section
it's not required for dependencies (since those are only ever between
sections, and not within), but makes for easier diffing.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-10-17 16:19:59 +02:00
Fabian Grünbichler
508e11f184 parse_user_cfg: correctly parse group names in ACLs
usernames are allowed to start with '@', so adding a user '@test@pve'
and adding it to an ACL should work, instead of ignoring that part of
the ACL entry.

So use verify_groupname to additionally enforce that the group name we
extracted does not include an additional @, as then it cannot be a
group.

note: there is no potential for user and group to be confused, since a
username must end with '@REALM', and a group reference in an ACL can
only contain one '@' (as first character).

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-10-03 10:47:44 +02:00
Thomas Lamprecht
e149b1c6c9 improve CSRF compat with older PVE
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-06-26 19:34:13 +02:00
Oguz Bektas
51e6f56d25 use hmac_sha256 instead of sha1 for csrf token
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2019-06-19 12:01:51 +02:00
Fabian Grünbichler
b8055a4fc0 ticket: add comments about auth key mtime
we cannot fully close this window, and don't need to anyway since we
apply +-300s when calculating ticket age ranges, but documenting where
mtime is used and what we expect seems like a good idea for future
readers.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-06-19 11:59:45 +02:00
Fabian Grünbichler
e770e6672f ticket: reorder calls when rotating
to shrink the window between the two file_set_contents calls. we don't
need the mtimes to line up exactly since we have 300s of uncertainty
anyway, but generating an RSA key could take a while ;)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-06-19 11:59:45 +02:00
Fabian Grünbichler
5bb966fe5d ticket: properly verify exactly 5min old tickets
to fix an issue where valid tickets could be rejected 5 minutes after a
key rotation, where the minimum age is exactly 0 seconds.

thanks Dominik for triaging!

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-06-19 11:59:45 +02:00
Thomas Lamprecht
243262f185 fix #2079: activate authkey rotation every 24 hours
This activates the authkey rotation added in commits
1800a71a79c7cf49108e22781d2f34be87b1efd through
f7282aee6b

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-05-21 22:07:41 +02:00
Wolfgang Bumiller
6063b65b9b tfa: realm required TFA should lock out users without TFA
This changed with the previous TFA changes.

In the long term, the plan is to let the user get into the
half-logged-in state and open the TFA configuration window
on the UI to allow them to finish their TFA setup, but for
now we restore the previous behavior.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-24 17:59:48 +00:00
Wolfgang Bumiller
0a956b943a typo fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-15 09:08:24 +02:00
Wolfgang Bumiller
7e58c66de2 store the tfa type in user.cfg
This allows some improvements to the user experience on the
web ui.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-12 16:27:53 +02:00
Wolfgang Bumiller
f25628d3ef verify_ticket: allow general non-challenge tfa to be run as two step call
This allows for doing OTP TFA in two steps, first login with normal
credentials and get the half-logged-in ticket, then send the OTP
verification for full login, same as with u2f was already possible.

This allows for a nicer UI, as OTP fields can be shown on demand, and
do not need to be visible by default.

The old way of sending the OTP code immediately with the initial
credentials request still works for backward compatibility and as
some API user may prefer it.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-08 14:48:13 +02:00
Thomas Lamprecht
49b15310ac followup: s/CUSTOM_TFA_TYPES/USER_CONTROLLED_TFA_TYPES/
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-04-03 13:34:23 +02:00
Wolfgang Bumiller
18f8ba1803 u2f authentication
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-03 08:04:00 +02:00
Wolfgang Bumiller
fda8ca85d3 more general 2FA configuration via priv/tfa.cfg
Adds a priv/tfa.cfg file usable in place of user.cfg.
(Otherwise the user.cfg can potentially grow too big with
u2f keys.)

Also contains some preparation code for u2f and
user-opt-in totp.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-04-03 08:04:00 +02:00
Dominik Csapak
5efff6c196 fix vnc ticket verification without authkey lifetime
since $authkey_lifetime is currently set to 0, we have to check this,
else we always fail to verify the VNC ticket

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2019-03-18 10:40:51 +01:00
Thomas Lamprecht
03593f3d01 fixup call to cfs_lock_authkey
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2019-03-14 11:18:43 +01:00
Fabian Grünbichler
21800a71a7 fix #2079: add periodic auth key rotation
and modify checks to accept still valid tickets generated using the
previous auth key.

the slightly complicated caching mechanism is needed for reading the key and
its modification timestamp in one go while only reading and parsing it again if
it has changed.

the +- 300 seconds fuzzing is kept for slightly out-of-sync clusters, since the
time encoded in the tickets is the result of time() on whichever node the
ticket API call got forwarded to.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-03-14 10:34:41 +01:00
Dominik Csapak
0fea3f1677 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>
2018-11-23 14:21:03 +01:00
Stoiko Ivanov
ab7b19b58c PVE::AccessControl: register userid with completion
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-27 16:40:55 +02:00
Stoiko Ivanov
b7ba86d426 fix PVE::AccessControl::role_is_special
PVE::AccessControl::role_is_special now returns 0 instead of '' for false
(Schemavalidation did complain about '')

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2018-06-27 16:40:55 +02:00
Philip Abernethy
16e50b59f9 properly register pve-poolid format
was erroneously registered as verify_groupname, overriding the previous
registration
2017-10-19 11:58:36 +02:00
Matthias Urban
aad513f6d1 VM.Snapshot.Rollback privilege added
VM.Snapshot.Rollback privilege added

Signed-off-by: Matthias Urban <matthias.urban@pure-systems.com>
2017-09-22 09:08:28 +02:00
Philip Abernethy
0a6e09fd47 Whitespace fixes
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-22 08:38:50 +02:00
Philip Abernethy
5654af83fa Remove unused Dumper uses
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-22 08:38:48 +02:00
Philip Abernethy
894e6f0c4b fix #1501: pveum: die when deleting special role
Die with a helpful error message instead of silently ignoring the user
when trying to delete a special role.
Also add a property to the API answer for possible later use by the
WebUI.

Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2017-09-22 08:38:21 +02:00
Dietmar Maurer
972859d115 use new PVE::OTP class from pve-common 2017-03-30 17:44:54 +02:00