2713 Commits

Author SHA1 Message Date
Stefan Sterz
4d6922e2c4 auth-api: move to hmac signing for csrf tokens
previously we used our own hmac-like implementation for csrf token
signing that simply appended the key to the message (csrf token).
however, this is possibly insecure as an attacker that finds a
collision in the hash function can easily forge a signature. after all,
two messages would then produce the same start conditions before
hashing the key. while this is probably a theoretic attack on our csrf
implementation, it does not hurt to move to the safer standard hmac
implementation that avoids such pitfalls.

this commit re-uses the hmac key wrapper used for the keyring. it also
keeps the old construction around so we can use it for a transition
period between old and new csrf token implementations.

this is a breaking change as it changes the signature of the
`csrf_secret` method of the `AuthContext` trait to return an hmac
key.

also exposes `assemble_csrf_prevention_toke` so we can re-use this
code here instead of duplicating it in e.g. proxmox-backup's
auth_helpers.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:40 +02:00
Stefan Sterz
8609fb58ef auth-api: use constant time comparison for csrf tokens
by using openssl's `memcmp::eq()` we can avoid potential side-channel
attack on the csrf token comparison. this comparison's runtime only
depends on the length of the two byte vectors, not their contents.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:38 +02:00
Stefan Sterz
b926ea1f5c auth-api: add ability to use hmac singing in keyring
previously we only used asymmetric cryptographic schemes to
authenticate tickets. this is fairly costly and not necessary in every
instance. imagine a service that runs as a single daemon. this daemon
is then the only party that needs to sign and verify tickets. this
makes hmac perfectly suitable for such usecases. hmac has some
advantages over asymmetric schemes:

- much simpler and well reviewed construction
- much faster and better optimized crypto primitives (hash functions)

this commit first introduces a new hmac key wrapper that uses openssl's
hmac implementation and can easily be reused by other parts of the
code. it also refactors the keyring code to make it easier to rotate
new hmac keys into place so switching to hmac keys is easier.

hmac keys are symmetric, so the verification key is the same key as the
signing key. this breaks the previous assumption by the keyring that
these correspond to public and private keys. thus, this commit
introduces two wrapper enums to distinguish between hmac and asymmetric
signature schemes.

the verification of hmac keys is also done via `openssl::memcmp::eq()`
to avoid potential timing side-channel attacks.

below are some simple benchmarks done with criterion.rs to show how much
faster hmac is, no matter the actual hash function:

rsa 4096 + sha256        time:   [2.7825 ms 2.7907 ms 2.7995 ms]
ed25519                  time:   [94.411 µs 94.840 µs 95.324 µs]
hmac sha256              time:   [5.7202 µs 5.7412 µs 5.7645 µs]
hmac sha384              time:   [6.6577 µs 6.6780 µs 6.7006 µs]
hmac sha3_256            time:   [5.6930 µs 5.7114 µs 5.7322 µs]

rsa with 4096 bit keys and a sha256 digest is our current default. the
test itself consists of a single sign + verification cycle. criterion
repeats this test as it sees fit to arrive at the above numbers.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:36 +02:00
Stefan Sterz
09d31a1a8b auth-api: move to Ed25519 signatures
previously we used P-256 as the curve of our choice for ec signatures.
however, in the meantime Ed25519 has become a lot more wide-spread.
this simplifies our ec generation code significantly while keeping the
same security level. Ed25519 was also specifically designed and
reviewed to avoid implementation errors likely making it a more secure
choice

note that Ed25519 as a signature scheme always uses sha512, so signing
or verifying with a chosen digest is not supported.

as this mostly affects newly generated keys, this should not break any
existing setups.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:35 +02:00
Stefan Sterz
8e566591d5 auth-api: move signing into the private key
this commit moves the current ticket signing code into the private key
implementation. the upside is that the caller does not need to deal
with openssl's `Signer` directly. it also simplifies and unifies the
code by using the same helper for verifying a signature and creating it.

also derive `Clone` on `PrivateKey` and `PublicKey`. as they are
essentially thin wrappers around `openssl::pkey::PKey<Private>` and
`openssl::pkey::PKey<Public>`, which can be cloned, deriving `Clone`
just makes them easier to use.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:33 +02:00
Dietmar Maurer
f240a2bfaa acme-api: add debian packaging
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-17 12:13:02 +02:00
Dietmar Maurer
7c899090e4 acme-api: use product-config instead of custom acme api configuration
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-17 11:52:57 +02:00
Dietmar Maurer
0ffe40fcfa bump proxmox-section-config to 2.0.2-1
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-17 11:04:10 +02:00
Dietmar Maurer
a2693c7046 section-config: pass filesystem paths as AsRef<Path>
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-17 10:59:20 +02:00
Dietmar Maurer
cfc155a06b acme-api: reusable ACME api implementation.
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 12:35:14 +02:00
Dietmar Maurer
870948f1d7 bump proxmox-acme to 0.5.2
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 11:53:52 +02:00
Dietmar Maurer
c07c46cd82 acme: add async-client feature
The client code is copied from propxmox-backup, without the load/safe
account functionality.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 11:48:17 +02:00
Dietmar Maurer
c2450691c6 acme: allow to compile/use api types separately.
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 11:23:19 +02:00
Dietmar Maurer
b082d7dafa system-management-api: network: add create_interface and update_interface
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 10:24:41 +02:00
Dietmar Maurer
2c0c7ca478 system-management: use ip/cidr schema types from proxmox-schema
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 09:42:10 +02:00
Dietmar Maurer
49b97b6a5f bump proxmox-schema to 3.1.1-1
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 09:35:50 +02:00
Dietmar Maurer
31b7b070b5 schema: api-types: add ip/cidr api schemas
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-16 09:09:37 +02:00
Dietmar Maurer
b74583dffe system-management-api: rename features (add suffix -api-types)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-15 13:33:55 +02:00
Dietmar Maurer
3c19dd757a rename proxmox-system-config-api to proxmox-system-management-api
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-15 13:23:42 +02:00
Dietmar Maurer
15e3779331 system-config-api: add syslog feature
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-15 12:31:50 +02:00
Dietmar Maurer
87aaa4e30a Revert "system-config-api: network: add alias 'iface' for interface name."
This reverts commit a4de726601d7f003833e4c040b9fcebe5adc26b4.

Turn out we do not need this.
2024-05-14 11:50:44 +02:00
Dietmar Maurer
26c7a591eb system-config-api: expose helpers to set ports/slaves as string (list)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-13 12:25:07 +02:00
Dietmar Maurer
805b1d366b system-config-api: network: add api type to update network interfaces
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-13 11:06:53 +02:00
Dietmar Maurer
c101194f5a system-config-api: cleanup: remove useless serde rename property 2024-05-10 11:15:12 +02:00
Dietmar Maurer
a4de726601 system-config-api: network: add alias 'iface' for interface name.
So that we can use the Interface struct with create and update api calls (which
currently use 'iface' instead of 'name').

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-10 10:23:27 +02:00
Dietmar Maurer
e210c85d8e system-config-api: network: add helpers to check for duplicate gateway propertie
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-10 10:08:23 +02:00
Dietmar Maurer
943cfd5417 system-config-api: network: add helpers to set bridge ports and bond slaves
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-10 09:53:27 +02:00
Dietmar Maurer
729817efd3 system-config-api: add network feature
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-10 09:53:05 +02:00
Dietmar Maurer
3e8b0ee567 system-config-api: use cargo features to sparate functionality
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-08 11:13:20 +02:00
Dietmar Maurer
770c5dbd03 system-config-api: add functions to read/write time and timezone
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-07 14:18:25 +02:00
Dietmar Maurer
751b578d6e rename proxmox-dns-api to proxmox-system-config-api
Because we want to bundle system configuration APIs in one crate,
i.e. Time, DNS, Network. We may separate them in future using
cargo features.
2024-05-07 13:32:26 +02:00
Dietmar Maurer
78bd8eea24 dns-api: add feature "impl"
So the we can use the api types with our UI crates.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-06 13:52:57 +02:00
Dietmar Maurer
96a3656dd2 product-config: add feature "impl"
So the we can use the ConfigDigest with our UI crates.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-06 13:40:32 +02:00
Dietmar Maurer
53ee3f92ea product-config: add method to detect config digest modifications.
Using an object method with strong typing is considered cleaner.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-06 13:01:36 +02:00
Dietmar Maurer
cb4e3776f2 dns-api: do not serlialize option None
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-06 10:29:49 +02:00
Dietmar Maurer
5d3c3a8770 dns-api: export all defined api types
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-03 09:51:34 +02:00
Dietmar Maurer
58bb112375 dns-api: add debian packaging
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-03 09:30:40 +02:00
Dietmar Maurer
03b4aed510 product-config: add debian packaging
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-03 09:29:46 +02:00
Dietmar Maurer
64e8a72a0b fix typo in proxmox-product-config workspace dependency
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-03 09:28:33 +02:00
Dietmar Maurer
c2f85d418a dns-api: new crate which implements the DNS api
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-02 13:04:43 +02:00
Dietmar Maurer
e64575b6a7 product-config: add rust API type for configuration digest
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-02 12:28:11 +02:00
Dietmar Maurer
9fc48d96d2 new crate for commonly used functions to read and write configuration files
Factor out functions to read and write configuration files with
product specific permissions.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-02 11:17:27 +02:00
Thomas Lamprecht
afb48baca5 metrics: bump version to 0.3.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:36:19 +02:00
Thomas Lamprecht
d426b6fe03 metrics: influxdb: inline variables into template format string
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:31:22 +02:00
Gabriel Goller
bfa73aadf8 metrics: encode influxdb org and bucket parameters
In order to remove the current limitations on the bucket and
organization names, we need to make sure that they are transmitted
correctly. In order to do this, we encode them using the url crate.

This way we support organization/bucket names that include slashes,
whitespaces, etc.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-04-26 17:25:52 +02:00
Thomas Lamprecht
5987eb0c3f sys: bump version to 0.5.4-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:24:23 +02:00
Thomas Lamprecht
c68b69e949 sys: bump version to 0.5.4-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 16:52:46 +02:00
Thomas Lamprecht
863d760340 auth-api: bump version to 0.3.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 21:22:33 +02:00
Thomas Lamprecht
bd944b06f9 ldap: bump version to 0.2.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 21:13:45 +02:00
Fabian Grünbichler
f4a9afd17c notify: fix TemplateType::Subject doc comment
wrongly copied

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-04-24 08:05:16 +02:00