5
0
mirror of git://git.proxmox.com/git/pve-access-control.git synced 2025-01-21 18:03:45 +03:00

569 Commits

Author SHA1 Message Date
Thomas Lamprecht
c0210e3cf1 api: realm sync: code cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 09:32:59 +02:00
Thomas Lamprecht
51ae7bbb69 realm sync: cleanup imports
with: perlimports -i --no-padding

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 09:31:40 +02:00
Dominik Csapak
dc982c4b76 add realm-sync plugin for jobs and CRUD api for realm-sync-jobs
to be able to define automated jobs that sync ldap/ad

The jobs plugin contains special handling when no node is given, since
we only want it to run on a single node when that triggers. For that,
we save a statefile in /etc/pve/priv/jobs/ which contains the
node/time/upid of the node that runs the job. The first node that
is able to lock the realm (via cfs_lock_domain) "wins" and may
sync from the ldap.

in case a specific node was selected, this is omitted and the Jobs
handling will not let it run on other nodes anyway

the API part is our usual sectionconfig CRUD api, but specialized
for the specific type of job.

the api will be at /cluster/jobs/realm-sync
(this must be done in pve-manager)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
 [ T: resolve merge conflict due to packaging/source split ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-07 08:01:07 +02:00
Wolfgang Bumiller
53a2b71563 api: user index: only include existing tfa lock flags
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-06 11:19:00 +02:00
Wolfgang Bumiller
f63364a755 bump version to 8.0.0~1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 14:52:39 +02:00
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
32893f1308 tfa: update list_tfa return schema
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 12:59:32 +02:00
Wolfgang Bumiller
ddf78dfbf3 cli: add 'tfa unlock' command
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
Wolfgang Bumiller
9036621e28 tfa: enable lockout of users via tfa.cfg
This will be accompanied by a change in pve-rs to finally
enable this.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 12:59:32 +02:00
Wolfgang Bumiller
209e9ab340 bump pve-rs dep to 0.8.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 12:59:32 +02:00
Wolfgang Bumiller
6c512352ae pam: set PAM_RHOST
This allows pam modules to restrict users by host. For
instance, you could restrict root@pam to only 127.0.0.1.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:53:42 +02:00
Wolfgang Bumiller
9d2996034d cli: add 'tfa list' command
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:53:31 +02:00
Wolfgang Bumiller
cfd8636b5e drop support for old login API
The new-format parameter for the ticket call is now ignored
and assumed 1.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:53:24 +02:00
Wolfgang Bumiller
cb64967379 api: drop old verify_tfa api call
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:53:18 +02:00
Wolfgang Bumiller
6b190c646e depend on pve-rs 0.8.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-22 10:27:15 +02:00
Wolfgang Bumiller
4a0d424f30 add anyevent to build deps
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-22 08:12:31 +02:00
Thomas Lamprecht
a3dc6ff488 bump version to 7.99.0
use a pre-release like version as we got some breaking changes
planned for access control, so might be nice to get (most of) them in
a 8.0.0 for simpler versioned  dependencies (>= 8~), but it's also
just a bit of an experiment to see how doing such things plays out,
in the end we can cope with whatever versioning for dependency as bug
fixes might make it necessary to have a more specific version
boundary anyway.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:44:21 +02:00
Thomas Lamprecht
e6911a0845 d/control: raise standards version compliance to 4.6.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:38:08 +02:00
Thomas Lamprecht
7426bae5c6 d/control: define compat level via build-depends and raise to 13
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
b08d939725 oathkeygen: modernize and improve error handling slightly
Note that this could also just be documented doing:

 dd if=/dev/urandom bs=1 count=10 2>/dev/null | base32

And using TOTP apps that can scan QR codes is much better UX anyway,
but its to trivial to bother deprecating it now and we'd still depend
on libmime-base32-perl, so really nothing gained in removing or
rewriting in shell..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
52910795a9 buildsys: add sbuild convenience target
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
474b2ce0f8 buildsys: cleanup and expand clean target
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
f71246d8c4 src makefiles: convert to use simple parenthesis
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
06d9a97f5b buildsys: drop useless packaging variable/includes in src
and allow overriding the PACKAGE variable, making it actually useful

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
2d3766be89 buildsys: rework clean target, avoid doc-gen one
1. this really doesn't change often
2. the synopsis and opts should be in the owner repo anyway
3. the original one simply deleted all *.adoc files, far to
   aggressive

Avoids pve-docs dependency for building the DSC (without having to
pass the ugly no-pre-clean option).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
e0b959c968 buildsys: derive upload dist automatically
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 12:37:11 +02:00
Thomas Lamprecht
6a003c5a14 buildsys: don't pass arch for an arch: all package
it was wrong too anyway, if, one would need to use the
$(DEB_HOST_ARCH), as that's the one package is built for.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 11:22:02 +02:00
Thomas Lamprecht
e4d6ad4d93 use combined dpkg packaging variable makefile fragment
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 11:17:45 +02:00
Thomas Lamprecht
a3744c5e8f makefile: convert to use simple parenthesis
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-21 10:52:58 +02:00
Wolfgang Bumiller
f2762a0359 bump version to 7.4-3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-16 13:33:54 +02:00
Wolfgang Bumiller
d9f02efe49 use TFA authentication api v2
Previously `authentication_verify` just `die`d on error and
would only return a boolean whether `priv/tfa.cfg` needs
updating as a positive result.

Since we want to support locking TOTP as well as a general
TFA lock-out via the config, we also want to be able to tell
when this occurs. Most of it is handled by the TFA rust
crate already, but notifying users needs to be done on this
end instead.

In pve-rs we now have a different API for this:
`authentication_verify2`, which, instead of die()ing on
errors, always returns a hash containing the result as well
as the flags 'tfa-limit-reached' and 'totp-limit-reached'
which, if set, tell us to notify the user.

However, doing so will introduce new fields in the
`priv/tfa.cfg` in a struct marked as `deny_unknown_fields`,
so in a cluster, the limits & notification handling should
only be done once we can be sure that all nodes are up to
date.

These fields are only introduced on login errors, so for
now, handle a failed result early without saving
`priv/tfa.cfg`.
The only case where saving the file was previously required
was when *successfully* logging in with a recovery key, by
which we cannot be reaching a limit, so this should still be
safe.

Once we can validate that all cluster nodes are up to date,
we can implement the notification system.
A commented-out code structure for this is included in this
patch.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-15 09:06:28 +02:00
Thomas Lamprecht
95fb22e696 fix various perlcritic lints
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-04-11 15:46:48 +02:00
Thomas Lamprecht
357ae0959f oathkeygen: code style fixes
we probably should just deprecate this altogether as it could be
worked around by doing a simple

 dd if=/dev/urandom bs=1 count=10 status=none | base32

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-04-11 15:15:43 +02:00
Thomas Lamprecht
f0595d158e bump version to 7.4-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-23 15:44:29 +01:00
Dominik Csapak
6b833faf93 fix #4609: allow valid DN in ldap/ad realm config
We previously added support for ',' in the DNS attribute through
allowing a quoted format, but the regex used was made too
restrictive.

In the new quoted attribute we'd only allow \w (alphanumeric and _)
and the restricted characters. This patch now changes that to allow
everything except the quotation mark " itself, which is again closer
to the original regex which did not care for quotation and allowed
everything aside from ','.

The unquoted attributes did not allow spaces anymore, but the RFC [0]
actually makes it clear that spaces are only forbidden at the
beginning and the end (same for #). So, fix the regex to accommodate
for that and allow space and # characters again if not at the end or
beginning.

0: https://www.ietf.org/rfc/rfc2253.txt

Fixes: 1aa2355 ("ldap: Allow quoted values for DN attribute values")
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
 [ T: make fixes a trailer and rework commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-23 15:41:47 +01:00
Thomas Lamprecht
a23eaa1a12 bump version to 7.4-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-20 17:16:15 +01:00
Christoph Heiss
1aa2355aed ldap: Allow quoted values for DN attribute values
This fixes #3748 by allowing reserved characters in `bind_dn` (and
other properties of the same format) if they are properly quoted and
adds some corresponding documentation regarding that.

This was tested by setting up a slapd server and creating a user with
the CN `Test, User` much like in the bug report, then using this user
as `bind_dn` in the sync options. I also tested some variants of that
CN, including just `TestUser`.)

One thing that still won't work is syncing of LDAP users with colons
or slashes in their CNs. In such cases, the message
> value 'Test, User@ldap' does not look like a valid user name
will pop up.

This is due to spaces and colons being explicitly disallowed in
usernames by PVE access-control's username schema. This probably
means that such names can never be allowed, which is being documented
too as separate pve-docs patch.

Note that while this is now a bit more strict for some cases too,
they should not matter in practice. For context; see RFC 2253 [0],
section 4. Interestingly, this document was obsoleted by RFC 4514 [1]
in 2006, which only mentions this in section 2.4 ("Converting an
AttributeValue from ASN.1 to a String") and appendix A ("Presentation
Issues").

But the first one seems to be the "authoritive" document on this
matter, at least looking at some other docs about LDAP DNs (RedHat,
Microsoft, ..).

[0] https://www.ietf.org/rfc/rfc2253.txt
[1] https://docs.ldap.com/specs/rfc4514.txt

Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
 [ T: added commit message ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-20 16:08:41 +01:00
Dominik Csapak
631b48745b realm sync: refactor scope/remove-vanished into a standard option
so that we can reuse it easily

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-03-08 12:42:00 +01:00
Thomas Lamprecht
df33b3b949 bump version to 7.3-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-06 11:40:15 +01:00
Thomas Lamprecht
1ef6c8fd8b userid format: clarify that this is the full name@realm in description
as it recently confused a user in the forum.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-03-06 10:41:39 +01:00
Fabian Grünbichler
170cf17bf7 fix #4518: improve ACL computation performance
by switching to a tree-based in-memory structure, like we do in PBS.

instead of parsing ACL entries into a hash using the full ACL path as key for
each entry, parse them into a tree-like nested hash. when evaluating ACLs,
iterating over all path prefixes starting at '/' is needed anyway, so this is a
more natural way to store and access the parsed configuration.

some performance data, timing `pveum user permissions $user > /dev/null` for
various amounts of ACL entries in user.cfg

entries | stock  | patched  | speedup
-------------------------------------
     1k | 1.234s |   0.241s |    5.12
     2k | 4.480s |   0.262s |   17.09
    20k |  7m25s |   0.987s |  450.86

similarly, an /access/ticket request such as the one happening on login goes
down from 4.27s to 109ms with 2k entries (testing with 20k entries fails
because the request times out after 30s, but with the patch it takes 336ms).

the underlying issue is that these two code paths not only iterate over *all
defined ACL paths* to get a complete picture of a user's/token's privileges,
but the fact that that ACL computation for each checked path itself did another
such loop in PVE::AccessControl::roles().

it is enough to iterate over the to-be-checked ACL path in a component-wise
fashion in order to handle role propagation, e.g., when looking at /a/b/c/d,
iterate over

/
/a
/a/b
/a/b/c
/a/b/c/d

in turn instead of all defined ACL paths.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-06 10:37:51 +01:00
Fabian Grünbichler
25fb12c4cb d/control: wrap-and-sort
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-10 14:49:35 +01:00
Fabian Grünbichler
c00ad67e40 build: add missing build-dependency
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-10 14:48:50 +01:00
Thomas Lamprecht
2da8c203f9 bump version to 7.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-12-16 13:11:08 +01:00
Dominik Csapak
982db92922 realm: sync: allow explicit 'none' for 'remove-vanished' option
with that, the api call can now override the default option
that is set on the realm (if any) by providing 'none'

it was not possible previously to override the realm default
when one wanted no properties to delete

no other code changes are necessary since we only extract the
known values 'acl' etc. and 'none' has no meaning there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-12-14 12:14:59 +01:00
Thomas Lamprecht
b84bf6238b bump version to 7.2-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-11-17 13:09:21 +01:00
Fabian Grünbichler
881dce13d5 privs: add Sys.Incoming
for guarding cross-cluster data streams like guest migrations and
storage migrations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-11-07 16:38:21 +01:00
Dominik Csapak
965b2418ee authenticate_user: pass undef instead of empty $tfa_challenge to authenticate_2nd_new
just above, we check & return if $tfa_challenge is set, so there is no
way that it would be set here. To make it clearer that it must be undef
here pass it as such.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-10-21 10:44:08 +02:00
Dominik Csapak
61565fb2c5 authenticate_2nd_new: rename $otp to $tfa_response
since that is what it really is, not only a otp

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2022-10-21 10:44:06 +02:00