]> git.proxmox.com Git - pve-access-control.git/log
pve-access-control.git
3 years agoticket: normalize path for verification
Fabian Grünbichler [Thu, 11 Nov 2021 14:07:12 +0000 (15:07 +0100)]
ticket: normalize path for verification

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agotickets: add tunnel ticket
Fabian Grünbichler [Thu, 11 Nov 2021 14:07:11 +0000 (15:07 +0100)]
tickets: add tunnel ticket

just like VNC ticket, but different prefix to prevent confusion.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agotfa: upgrade check: early return if no cluster members
Thomas Lamprecht [Thu, 11 Nov 2021 11:29:58 +0000 (12:29 +0100)]
tfa: upgrade check: early return if no cluster members

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agotfa: upgrade check: more info in error message(s)
Thomas Lamprecht [Thu, 11 Nov 2021 11:06:42 +0000 (12:06 +0100)]
tfa: upgrade check: more info in error message(s)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agotfa: upgrade check: be less strict about version format
Thomas Lamprecht [Thu, 11 Nov 2021 11:05:52 +0000 (12:05 +0100)]
tfa: upgrade check: be less strict about version format

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoimplement version checks for tfa
Wolfgang Bumiller [Wed, 10 Nov 2021 14:11:45 +0000 (15:11 +0100)]
implement version checks for tfa

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agomerge old user.cfg keys to tfa config when adding entries
Wolfgang Bumiller [Wed, 10 Nov 2021 12:49:03 +0000 (13:49 +0100)]
merge old user.cfg keys to tfa config when adding entries

this happens when the first new tfa entry is added and the
'keys' entry is replaced by "x"

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/control: add liburi-perl dependency
Wolfgang Bumiller [Wed, 10 Nov 2021 12:49:02 +0000 (13:49 +0100)]
d/control: add liburi-perl dependency

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agocheck enforced realm tfa type in new auth
Wolfgang Bumiller [Wed, 10 Nov 2021 12:49:01 +0000 (13:49 +0100)]
check enforced realm tfa type in new auth

this way we could also add webauthn as a required tfa type
to the realm configs later on

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoassert tfa/user config lock order
Wolfgang Bumiller [Wed, 10 Nov 2021 12:49:00 +0000 (13:49 +0100)]
assert tfa/user config lock order

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoset/remove 'x' for tfa keys in user.cfg in new api
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:05 +0000 (12:27 +0100)]
set/remove 'x' for tfa keys in user.cfg in new api

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agopveum: update tfa delete command
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:04 +0000 (12:27 +0100)]
pveum: update tfa delete command

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoupdate tfa cleanup when deleting users
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:03 +0000 (12:27 +0100)]
update tfa cleanup when deleting users

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agosupport registering yubico otp keys
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:02 +0000 (12:27 +0100)]
support registering yubico otp keys

In PBS we don't support this, so the current TFA API in rust
does not support this either (although the config does know
about its *existence*).

For now, yubico authentication will be done in perl. Adding
it to rust the rust TFA crate would not make much sense
anyway as we'd likely not want to use the same http client
crate in pve and pbs anyway (since pve is all blocking code
and pbs is async...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadd pbs-style TFA API implementation
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:01 +0000 (12:27 +0100)]
add pbs-style TFA API implementation

implements the same api paths as in pbs by forwarding the
api methods to the rust implementation after performing the
product-specific checks

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agomove TFA api path into its own module
Wolfgang Bumiller [Tue, 9 Nov 2021 11:27:00 +0000 (12:27 +0100)]
move TFA api path into its own module

and remove old modification api

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agohandle yubico authentication in new path
Wolfgang Bumiller [Tue, 9 Nov 2021 11:26:59 +0000 (12:26 +0100)]
handle yubico authentication in new path

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agouse PBS-like auth api call flow
Wolfgang Bumiller [Tue, 9 Nov 2021 11:26:58 +0000 (12:26 +0100)]
use PBS-like auth api call flow

The main difference here is that we have no separate api
path for verification. Instead, the ticket api call gets an
optional 'tfa-challenge' parameter.

This is opt-in: old pve-manager UI with new
pve-access-control will still work as expected, but users
won't be able to *update* their TFA settings.

Since the new tfa config parser will build a compatible
in-perl tfa config object as well, the old authentication
code is left unchanged for compatibility and will be removed
with pve-8, where the `new-format` parameter in the ticket
call will change its default to `1`.

The `change_tfa` call will simply die in this commit. It is
removed later when adding the pbs-style TFA API calls.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoupdate read_user_tfa_type call
Wolfgang Bumiller [Tue, 9 Nov 2021 11:26:57 +0000 (12:26 +0100)]
update read_user_tfa_type call

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agouse rust parser for TFA config
Wolfgang Bumiller [Tue, 9 Nov 2021 11:26:56 +0000 (12:26 +0100)]
use rust parser for TFA config

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoopenid: proxy: only set env var if DC-config property exists
Thomas Lamprecht [Wed, 3 Nov 2021 10:30:05 +0000 (11:30 +0100)]
openid: proxy: only set env var if DC-config property exists

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofix #3513: pass configured proxy to OpenID
Fabian Grünbichler [Tue, 13 Jul 2021 08:09:17 +0000 (10:09 +0200)]
fix #3513: pass configured proxy to OpenID

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agobump version to 7.0-6
Thomas Lamprecht [Thu, 21 Oct 2021 10:28:58 +0000 (12:28 +0200)]
bump version to 7.0-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofix user deletion when realm does not enforce TFA
Dominik Csapak [Tue, 19 Oct 2021 11:52:42 +0000 (13:52 +0200)]
fix user deletion when realm does not enforce TFA

here the existance of the user is only interesting if we want to set
data, not if we delete it.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agobump version to 7.0-5
Thomas Lamprecht [Mon, 27 Sep 2021 13:50:50 +0000 (15:50 +0200)]
bump version to 7.0-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: delete user: better communicate partial deletion
Thomas Lamprecht [Mon, 27 Sep 2021 13:46:26 +0000 (15:46 +0200)]
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>
3 years agoapi: delete user: disable first to avoid surprise on error
Thomas Lamprecht [Mon, 27 Sep 2021 13:32:38 +0000 (15:32 +0200)]
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>
3 years agofix #2302: allow deletion of users when realm enforces TFA
Thomas Lamprecht [Mon, 27 Sep 2021 13:31:31 +0000 (15:31 +0200)]
fix #2302: allow deletion of users when realm enforces TFA

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: user: indentation & whitspace cleanups
Thomas Lamprecht [Thu, 23 Sep 2021 12:16:50 +0000 (14:16 +0200)]
api: user: indentation & whitspace cleanups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agocheck_path: add /sdn/vnets/* path
Alexandre Derumier [Thu, 5 Aug 2021 15:00:44 +0000 (17:00 +0200)]
check_path: add /sdn/vnets/* path

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
3 years agobump version to 7.0-4
Thomas Lamprecht [Fri, 2 Jul 2021 11:45:51 +0000 (13:45 +0200)]
bump version to 7.0-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: users: use public regex directly to parse out realm
Thomas Lamprecht [Fri, 2 Jul 2021 11:42:16 +0000 (13:42 +0200)]
api: users: use public regex directly to parse out realm

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: users: code-style cleanup and sort when iterating users
Thomas Lamprecht [Fri, 2 Jul 2021 11:41:29 +0000 (13:41 +0200)]
api: users: code-style cleanup and sort when iterating users

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: users: s/realmtype/realm-type/ in response
Thomas Lamprecht [Fri, 2 Jul 2021 11:38:46 +0000 (13:38 +0200)]
api: users: s/realmtype/realm-type/ in response

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: user: add realmtype to user list
Dominik Csapak [Thu, 1 Jul 2021 12:25:00 +0000 (14:25 +0200)]
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>
3 years agoimplement OpenID autocreate user feature
Dietmar Maurer [Wed, 30 Jun 2021 06:10:07 +0000 (08:10 +0200)]
implement OpenID autocreate user feature

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: implement openid API
Dietmar Maurer [Wed, 30 Jun 2021 06:10:06 +0000 (08:10 +0200)]
api: implement openid API

This moves compute_api_permission() into RPCEnvironment.pm.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agodepend on libpve-rs-perl
Dietmar Maurer [Wed, 30 Jun 2021 06:10:05 +0000 (08:10 +0200)]
depend on libpve-rs-perl

3 years agoadd OpenId configuration
Dietmar Maurer [Wed, 30 Jun 2021 06:10:04 +0000 (08:10 +0200)]
add OpenId configuration

3 years agocheck_user_enabled: also check if user is expired
Dietmar Maurer [Wed, 30 Jun 2021 06:10:03 +0000 (08:10 +0200)]
check_user_enabled: also check if user is expired

3 years agobump version to 7.0-3
Thomas Lamprecht [Mon, 21 Jun 2021 08:31:23 +0000 (10:31 +0200)]
bump version to 7.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobuildsys: clean more
Thomas Lamprecht [Thu, 17 Jun 2021 12:43:44 +0000 (14:43 +0200)]
buildsys: clean more

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoaccess control: style: register configs in single line each
Thomas Lamprecht [Thu, 17 Jun 2021 12:41:02 +0000 (14:41 +0200)]
access control: style: register configs in single line each

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agocheck_path : add sdn zone path
Alexandre Derumier [Wed, 9 Jun 2021 04:37:30 +0000 (06:37 +0200)]
check_path : add sdn zone path

This was missing in commit20c60513b2a6b2d7c7aae0dcc0391889b9cb7ecf,
so user can't assign permisson on a zone currently

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd missing paths in check_path
Dominik Csapak [Wed, 16 Jun 2021 13:55:34 +0000 (15:55 +0200)]
add missing paths in check_path

* /access/realm/<realm>
* /access/groups/<group>

were overlooked when fixing #1500

see: https://forum.proxmox.com/threads/are-group-acls-broken-in-v6-4.91000/

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agorpc env: sort use statements
Thomas Lamprecht [Tue, 15 Jun 2021 12:38:41 +0000 (14:38 +0200)]
rpc env: sort use statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobuildsys: change upload dist to bullseye
Thomas Lamprecht [Tue, 8 Jun 2021 07:47:21 +0000 (09:47 +0200)]
buildsys: change upload dist to bullseye

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 7.0-2
Fabian Grünbichler [Tue, 1 Jun 2021 09:29:49 +0000 (11:29 +0200)]
bump version to 7.0-2

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agofix #3402: add Pool.Audit permission
Lorenz Stechauner [Thu, 20 May 2021 10:03:39 +0000 (12:03 +0200)]
fix #3402: add Pool.Audit permission

add new user "PVEPoolUser" and add Pool.Audit to "PVEAuditor".

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
3 years agod/control: add missing libuuid-perl b-d
Fabian Grünbichler [Tue, 18 May 2021 11:17:16 +0000 (13:17 +0200)]
d/control: add missing libuuid-perl b-d

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
3 years agobump version to 7.0-1
Thomas Lamprecht [Sun, 9 May 2021 16:18:39 +0000 (18:18 +0200)]
bump version to 7.0-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopveum: work around unavailable API2:Pools module
Thomas Lamprecht [Sun, 9 May 2021 17:46:53 +0000 (19:46 +0200)]
pveum: work around unavailable API2:Pools module

commit 42ade84744ab60ff8e452d3e562a36dd3da2b810 added the pool
subcommands, reusing the PVE::API2::Pool module. But that module has
to live in pve-manager and is not available here, most of the time
not a real issue (but always ugly), on bootstrapping this becomes a
blocker though...

So, for now add a hack and do not hard depend on the modules
availability...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/control: update standards version
Thomas Lamprecht [Sun, 9 May 2021 17:46:31 +0000 (19:46 +0200)]
d/control: update standards version

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/control: drop perl dependency, added by ${perl:Depends}
Thomas Lamprecht [Sun, 9 May 2021 17:46:17 +0000 (19:46 +0200)]
d/control: drop perl dependency, added by ${perl:Depends}

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobuildsys: split packaging and source build-systems
Thomas Lamprecht [Sun, 9 May 2021 17:37:47 +0000 (19:37 +0200)]
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>
3 years agod/control: bump debhelper compat to >= 12
Thomas Lamprecht [Sun, 9 May 2021 16:16:38 +0000 (18:16 +0200)]
d/control: bump debhelper compat to >= 12

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/rules: fix dh_missing override
Thomas Lamprecht [Sun, 9 May 2021 16:16:03 +0000 (18:16 +0200)]
d/rules: fix dh_missing override

note, with compat level >= 13 we can drop that override finally

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.4-1
Thomas Lamprecht [Sat, 24 Apr 2021 17:48:25 +0000 (19:48 +0200)]
bump version to 6.4-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoresource pools: add resource pool cli commands
Dylan Whyte [Fri, 29 Jan 2021 07:54:39 +0000 (08:54 +0100)]
resource pools: add resource pool cli commands

Add commands for creating, modifying, listing, and deleting resource
pools.

Signed-off-by: Dylan Whyte <d.whyte@proxmox.com>
3 years agofix typo in oathkeygen: randon -> random
Lorenz Stechauner [Tue, 20 Apr 2021 12:11:55 +0000 (14:11 +0200)]
fix typo in oathkeygen: randon -> random

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
3 years agoacl: check path: further resdtrict VMID values
Thomas Lamprecht [Mon, 19 Apr 2021 09:50:16 +0000 (11:50 +0200)]
acl: check path: further resdtrict VMID values

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoacl: check path: spell param out
Thomas Lamprecht [Mon, 19 Apr 2021 09:48:49 +0000 (11:48 +0200)]
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>
3 years agofix #1500: permission path syntax check for access control
Lorenz Stechauner [Mon, 19 Apr 2021 07:16:28 +0000 (09:16 +0200)]
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>
4 years agofix #1670: change PAM service name to project specific name
Wolfgang Bumiller [Fri, 20 Nov 2020 10:05:34 +0000 (11:05 +0100)]
fix #1670: change PAM service name to project specific name

Instead of 'common-auth' use 'proxmox-ve-auth', this way
users can override PAM authentication settings via
`/etc/pam.d/proxmox-ve-auth`.

If the file does not exist, pam will use `/etc/pam.d/other`
which by default behaves like `common-auth`.

Note that this *can* be different from directly using
`common-auth` *if* a user has actually modified
`/etc/pam.d/other` for some reason.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 years agobump version to 6.1-3
Thomas Lamprecht [Tue, 29 Sep 2020 06:53:56 +0000 (08:53 +0200)]
bump version to 6.1-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/users: catch existing user also on case insensitive realm
Thomas Lamprecht [Tue, 29 Sep 2020 05:09:51 +0000 (07:09 +0200)]
api/users: catch existing user also on case insensitive realm

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/users: indentation cleanup
Thomas Lamprecht [Tue, 29 Sep 2020 04:19:07 +0000 (06:19 +0200)]
api/users: indentation cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix #2947 login name for the LDAP/AD realm can be case-insensitive
Wolfgang Link [Tue, 8 Sep 2020 12:09:45 +0000 (14:09 +0200)]
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>
4 years agopartially fix #2825: authkey: rotate if it was generated in the future
Thomas Lamprecht [Fri, 3 Jul 2020 09:06:55 +0000 (11:06 +0200)]
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>
4 years agoauthkey: use variable instead of hard coded grace period value
Thomas Lamprecht [Fri, 3 Jul 2020 13:18:11 +0000 (15:18 +0200)]
authkey: use variable instead of hard coded grace period value

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-2
Thomas Lamprecht [Tue, 30 Jun 2020 11:06:59 +0000 (13:06 +0200)]
bump version to 6.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agointroduce VM.Config.Cloudinit permission
Mira Limbeck [Thu, 25 Jun 2020 14:48:46 +0000 (16:48 +0200)]
introduce VM.Config.Cloudinit permission

It is added to PVEVMUser by default.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
4 years agoapi2: AccessControl: add sdn permissions.modify
Alexandre Derumier [Fri, 12 Jun 2020 09:53:22 +0000 (11:53 +0200)]
api2: AccessControl: add sdn permissions.modify

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
4 years agocomput coarse UI permissions: also check SDN ones
Thomas Lamprecht [Tue, 9 Jun 2020 09:43:51 +0000 (11:43 +0200)]
comput coarse UI permissions: also check SDN ones

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.1-1
Thomas Lamprecht [Fri, 8 May 2020 15:47:50 +0000 (17:47 +0200)]
bump version to 6.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoLDAP: skip anonymous bind when clientcert/key is given
Dominik Csapak [Fri, 8 May 2020 11:16:58 +0000 (13:16 +0200)]
LDAP: skip anonymous bind when clientcert/key is given

It seems that servers associate the client-cert/key with an account, so
doing an explicit anonymous bind then 'logs out' the already verified
user, limiting the search results in some cases

before refactoring to PVE::LDAP, we did not do '$ldap->bind' at all when
there was no bind_dn, but it is not really clear if Net::LDAP does this
automatically when searching (other libraries do this), so leave the
anonymous bind (for compatibility with PMG) but skip it when a client
certificate and key is given.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoldap_delete_credentials: don't complain if already deleted
Thomas Lamprecht [Fri, 8 May 2020 07:38:34 +0000 (09:38 +0200)]
ldap_delete_credentials: don't complain if already deleted

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agowhitespace cleanup
Tim Marx [Wed, 6 May 2020 12:00:53 +0000 (14:00 +0200)]
whitespace cleanup

Signed-off-by: Tim Marx <t.marx@proxmox.com>
4 years agopveum: add 'tfa delete' subcommand for deleting user-TFA
Thomas Lamprecht [Sun, 3 May 2020 14:40:03 +0000 (16:40 +0200)]
pveum: add 'tfa delete' subcommand for deleting user-TFA

Allows a user to straight forward delete TFS over CLI, easier as
telling them to edit some config files, and the API is already there.

Short circuit most params of that API call to undef, as they do not
make sense to expose.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.0-7
Thomas Lamprecht [Sat, 25 Apr 2020 17:35:20 +0000 (19:35 +0200)]
bump version to 6.0-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodomains: dry-run: adapt log messages and improve variable name
Thomas Lamprecht [Sat, 25 Apr 2020 16:55:35 +0000 (18:55 +0200)]
domains: dry-run: adapt log messages and improve variable name

keep variable names aligned with the params the relate to, "write"
was quite ambiguous too (write what?)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoparse_sync_opts: code cleanup
Thomas Lamprecht [Sat, 25 Apr 2020 16:54:45 +0000 (18:54 +0200)]
parse_sync_opts: code cleanup

avoid confusion between fmt default and cfg default

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodomain sync: add 'dry-run' parameter
Dominik Csapak [Thu, 23 Apr 2020 06:47:19 +0000 (08:47 +0200)]
domain sync: add 'dry-run' parameter

this can be used to test the resulting config before actually changing
anything

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoauth ldap/ad: introduce connection 'mode'
Dominik Csapak [Thu, 23 Apr 2020 06:47:18 +0000 (08:47 +0200)]
auth ldap/ad: introduce connection 'mode'

instead of having only a 'secure' flag which switches between
ldap/ldaps we now have a mode which also contains 'ldap+starttls'

our connection code in PVE::LDAP can handle this already (used in pmg)
so that is no problem

if we want to really remove the 'secure' flag, e.g. in 7.0
we'd either have to rewrite the config or have it as an error
in a pve6to7 script

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agodomain sync: make options actually required
Dominik Csapak [Thu, 23 Apr 2020 06:47:17 +0000 (08:47 +0200)]
domain sync: make options actually required

we want the api options to be optional, but only as long as there are
default values set in the realm config

since they are all marked as optional (else they would be required in
the api) this check did not work as intended

instead, set the result to the value of:
* the parameter
* the set default in the config
* the api default
in this order

if it is undef after this, raise a parameter exception

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoauth ldap/ad: make password a parameter for the api
Dominik Csapak [Wed, 8 Apr 2020 07:00:53 +0000 (09:00 +0200)]
auth ldap/ad: make password a parameter for the api

Allows us to add it in the gui, until now the admin needed to create
the file themself.

Mirrored after credential handling from CIFS and PBS in their
pve-storage plugins

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
[Thomas: don't differ from storage one unnecessarily, keep comments
 and behavior]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi/domain: add on add/update/delete hooks
Thomas Lamprecht [Sat, 18 Apr 2020 16:47:37 +0000 (18:47 +0200)]
api/domain: add on add/update/delete hooks

Almost 1:1 taken from pve-storage ones

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agotoken create: return also full token id for convenience
Thomas Lamprecht [Wed, 15 Apr 2020 18:41:38 +0000 (20:41 +0200)]
token create: return also full token id for convenience

makes creating a client for this slightly nicer, as it doesn't needs
to be as state full.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobuildsys: fix getting the build commit
Thomas Lamprecht [Wed, 15 Apr 2020 18:04:54 +0000 (20:04 +0200)]
buildsys: fix getting the build commit

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agotoken: avoid undef warning if no tokens are configured
Thomas Lamprecht [Wed, 15 Apr 2020 15:13:59 +0000 (17:13 +0200)]
token: avoid undef warning if no tokens are configured

Initially the config may not even exist, and so the first token
create would give one then a ugly warning like:
> Use of uninitialized value $raw in split at ..

Handle that case, empty config (where we get '') was fine already, so
explicitly check for definedness, not truthiness.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoauth ad: add sync-defaults-options
Dominik Csapak [Mon, 6 Apr 2020 11:31:52 +0000 (13:31 +0200)]
auth ad: add sync-defaults-options

this was missing for AD realms

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agod/control: bump versioned to libpve-common-perl
Thomas Lamprecht [Sat, 21 Mar 2020 15:51:06 +0000 (16:51 +0100)]
d/control: bump versioned to libpve-common-perl

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agosplit and sort some module use
Thomas Lamprecht [Sat, 21 Mar 2020 15:04:44 +0000 (16:04 +0100)]
split and sort some module use

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agorealm: add default-sync-options to config
Thomas Lamprecht [Sat, 21 Mar 2020 15:01:56 +0000 (16:01 +0100)]
realm: add default-sync-options to config

This allows us to have a convenient way to set the desired default
sync options, and thus not forcing users to pass always all options
when they want to trigger a sync.

We still die when an option is neither specified in the domains
(realm) config nor as API/CLI parameter.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: realm sync: move out group and user update to separate methods
Thomas Lamprecht [Sat, 21 Mar 2020 14:56:51 +0000 (15:56 +0100)]
api: realm sync: move out group and user update to separate methods

keep the api call way smaller and clearer

On moving out some minor adaptions where made, e.g., we do not print
"remove user X" if we know that we'd add it again, but just print a
single "update user X" for that. Same for groups.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: realm sync: use auth-realm-sync as worker id
Thomas Lamprecht [Sat, 21 Mar 2020 15:07:49 +0000 (16:07 +0100)]
api: realm sync: use auth-realm-sync as worker id

we may potentially also sync something else over this in the future,
for example PAM users from a specific group, so use a more general
name.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: realm sync: cleanup code and refactor
Thomas Lamprecht [Sat, 21 Mar 2020 14:55:30 +0000 (15:55 +0100)]
api: realm sync: cleanup code and refactor

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agodo not modify ACLs/Groups for missing users
Dominik Csapak [Fri, 13 Mar 2020 12:18:48 +0000 (13:18 +0100)]
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>
4 years agoapi: domains: add user/group sync API enpoint
Dominik Csapak [Fri, 13 Mar 2020 12:18:47 +0000 (13:18 +0100)]
api: domains: add user/group sync API enpoint

this api call syncs the users and groups from LDAP/AD to the
user.cfg

it also implements a 'full' mode where we first delete all
users/groups from the config and sync them again

the parameter 'enable' controls if newly synced users are 'enabled'
(if no sync parameter handles that)
the parameter 'purge' controls if ACLs get removed for users/groups
that do not exists anymore after

also add this command to pveum

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoAuth/AD: make PVE::Auth::AD a subclass of PVE::Auth::LDAP
Dominik Csapak [Fri, 13 Mar 2020 12:18:46 +0000 (13:18 +0100)]
Auth/AD: make PVE::Auth::AD a subclass of PVE::Auth::LDAP

this makes it much easier to reuse the sync code from LDAP in AD.
The 'authenticate_user' sub is still the same, but we now
can still use the get_users and get_groups functionality of LDAP

in the case of AD, the user_attr is optional in the config
(would have been a breaking change) but we set it
to default to 'sAMAccountName'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>