Commit Graph

2184 Commits

Author SHA1 Message Date
Wolfgang Bumiller
33d9ea78ef bump proxmox-apt to 0.10.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:53:44 +02:00
Wolfgang Bumiller
d0bce77e50 bump proxmox-human-byte to 0.1.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:53:44 +02:00
Wolfgang Bumiller
93fc5b503a bump proxmox-router to 2.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:53:44 +02:00
Wolfgang Bumiller
ac6a52dfd1 bump proxmox-schema to 2.0.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:42:14 +02:00
Lukas Wagner
b46d333d98 notify: add debian packaging
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
[w.bumiller@proxmox.com: set d/changelog to UNRELEASED]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-24 10:34:52 +02:00
Lukas Wagner
9b726bb072 notify: additional logging when sending a notification
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:26:08 +02:00
Lukas Wagner
2756c11c2f notify: ensure that filter/group/endpoint names are unique
Otherwise, a filter with the same name as an already existing
endpoint or group can overwrite it.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:26:06 +02:00
Lukas Wagner
62ae1cf959 notify: on deletion, check if a filter/endp. is still used by anything
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:26:04 +02:00
Lukas Wagner
3c9584296f notify: api: allow to query entities referenced by filter/target
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:26:02 +02:00
Lukas Wagner
d44ce2c70d notify: gotify: add proxy support
The proxy configuration will be read from datacenter.cfg via
a new method of the `Context` trait.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:26:01 +02:00
Lukas Wagner
da2e7b8da9 notify: sendmail: query default author/mailfrom from context
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:59 +02:00
Lukas Wagner
c5f91aa1c8 notify: sendmail: allow users as recipients
This introduces a new configuration parameter `mailto-user`.
A user's email address will be looked up in the product-specific
user database.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:57 +02:00
Lukas Wagner
d6c1f181d6 notify: add context
Since `proxmox-notify` is intended to be used by multiple products,
there needs to be a way to inject product-specific behavior.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:51 +02:00
Lukas Wagner
97dac11823 notify: add example for template rendering
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:49 +02:00
Lukas Wagner
4865711339 notify: add template rendering
This commit adds template rendering to the `proxmox-notify` crate, based
on the `handlebars` crate.

Title and body of a notification are rendered using any `properties`
passed along with the notification. There are also a few helpers,
allowing to render tables from `serde_json::Value`.

'Value' renderers. These can also be used in table cells using the
'renderer' property in a table schema:
  - {{human-bytes val}}
    Render bytes with human-readable units (base 2)
  - {{duration val}}
    Render a duration (based on seconds)
  - {{timestamp val}}
    Render a unix-epoch (based on seconds)

There are also a few 'block-level' helpers.
  - {{table val}}
    Render a table from given val (containing a schema for the columns,
    as well as the table data)
  - {{object val}}
    Render a value as a pretty-printed json
  - {{heading_1 val}}
    Render a top-level heading
  - {{heading_2 val}}
    Render a not-so-top-level heading
  - {{verbatim val}} or {{/verbatim}}<content>{{#verbatim}}
    Do not reflow text. NOP for plain text, but for HTML output the text
    will be contained in a <pre> with a regular font.
  - {{verbatim-monospaced val}} or
      {{/verbatim-monospaced}}<content>{{#verbatim-monospaced}}
    Do not reflow text. NOP for plain text, but for HTML output the text
    will be contained in a <pre> with a monospaced font.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:48 +02:00
Lukas Wagner
109a936b6b notify: api: add API for filters
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:46 +02:00
Lukas Wagner
ee0ab52b9b notify: add notification filter mechanism
This commit adds a way to filter notifications based on severity. The
filter module also has the necessary foundation work for more complex
filters, e.g. matching on properties or for creating arbitarily complex
filter structures using nested sub-filters.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:43 +02:00
Lukas Wagner
ee44fdca04 notify: api: add API for groups
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:41 +02:00
Lukas Wagner
ed5d27ba24 notify: add notification groups
When notifying via a group, all endpoints contained in that group
will send out the notification.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:39 +02:00
Lukas Wagner
055db2d107 notify: api: add API for gotify endpoints
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:37 +02:00
Lukas Wagner
990fc8efd2 notify: add gotify endpoint
Add an endpoint for Gotify [1], showing the how easy it is to add new
endpoint implementations.

[1] https://gotify.net/

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:35 +02:00
Lukas Wagner
21c5c9a0c7 notify: api: add API for sendmail endpoints
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:33 +02:00
Lukas Wagner
7c42752690 notify: add sendmail plugin
This plugin uses the 'sendmail' command to send an email
to one or more recipients.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:31 +02:00
Lukas Wagner
714ef27786 notify: api: add API for sending notifications/testing endpoints
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:30 +02:00
Lukas Wagner
ad3f78a315 notify: preparation for the API
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:28 +02:00
Lukas Wagner
2726e68afe notify: preparation for the first endpoint plugin
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:27 +02:00
Lukas Wagner
b8040a23cb add proxmox-notify crate
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:25 +02:00
Lukas Wagner
82be261447 schema: add schema/format for comments
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:22 +02:00
Lukas Wagner
8013a80b41 section-config: derive Clone for SectionConfigData
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:20 +02:00
Wolfgang Bumiller
f6e089555e schema: verify property strings w/ new serde code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:19 +02:00
Wolfgang Bumiller
12da5121ff schema: predictable order of errors for tests
Otherwise we'd have to "search" & match the errors...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:17 +02:00
Wolfgang Bumiller
c702638bd8 schema: fixup empty error list handling
Some(<empty list of errors>) does not actually signal an error...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:16 +02:00
Wolfgang Bumiller
aa10025366 schema: guard property string constraint checking
StringSchema::check_constraint runs `parse_property_string` for
property strings, but when we deserialize a `PropertyString` we
immediately follow that up with deserializing it using the schema, so
there's no need to check it beforehand.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:13 +02:00
Wolfgang Bumiller
1a46283b78 schema: get rid of some unsafe code
the borrow tracking won't hurt...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:11 +02:00
Wolfgang Bumiller
73a20c7f5f schema: use schema when serializing property strings
Adds a Schema to the `PropertyString` type and uses it for better
serialization.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:09 +02:00
Wolfgang Bumiller
413d631fa6 schema: convenience accessors to schema subtypes
Adds `const fn <type>(&self) -> Option<&<Type>Schema>` methods to
`Schema`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:05 +02:00
Wolfgang Bumiller
5a64f3258a schema: serde based property string de- and serialization
This provides `proxmox_schema::property_string::PropertyString<T>` for
a typed property-string.

To facilitate this, this introduces
`proxmox_schema:🇩🇪:SchemaDeserializer` which is a serde deserializer
for property strings given a schema.

This basically maps to one of `de::SeqAccess` (for array schemas) or
`de::MapAccess` (for object schemas).

Additionally, a `de::NoSchemaDeserializer` is added, since properties
within the strings may have string schemas with no format to it, while
the type we serialize to may ask for an array (a simple "list") via
serde.

The deserializers support borrowing, for which a helper `Cow3` needed
to be added, since property strings support quoting with escape
sequences where an intermediate string would be allocated and with an
intermediate lifetime distinct from the `'de` lifetime.

A `de::verify` module is added which uses serde infrastructure to
validate schemas without first having to deserialize a complete
`serde_json::Value`.

For serialization, `proxmox_schema::ser::PropertyStringSerializer` is
added split into similar parts `ser::SerializeStruct` and
`ser::SerializeSeq` at the top level, and the same prefixed with
`Element` for inside the actual string. This should also properly
quote the contents if required.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:18:58 +02:00
Wolfgang Bumiller
4ca8dbf74f auth-api: fixup examples
These were missing the new client-ip parameter in the auth
function calls which was introduced to support `PAM_RHOST`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-10 09:06:35 +02:00
Thomas Lamprecht
ec5e2a5d90 proxmox-apt: bump to 0.10.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-05 12:38:08 +02:00
Wolfgang Bumiller
50136f1817 bump proxmox-tfa to 4.0.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-05 10:46:12 +02:00
Wolfgang Bumiller
8547ee31da tfa: also reset counters when unlocking tfa
Since this requires access to the user data, we need to add
a generic parameter to the unlock methods.
To avoid having to create another major API bump affecting
all our products this short after release, we keep the old
version around with the old behavior.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-04 14:45:18 +02:00
Fabian Grünbichler
415d60daf9 release file: extend component fixup to bookworm
else mirroring bookworm-security will skip *all* components..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-29 13:11:17 +02:00
Thomas Lamprecht
2a070da065 proxmox-rest-server: bump to 0.4.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-27 12:44:52 +02:00
Thomas Lamprecht
880abd859b proxmox-apt: bump version to 0.10.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-27 12:36:05 +02:00
Wolfgang Bumiller
54cb9be8ed bump proxmox-ldap to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 14:22:50 +02:00
Stefan Sterz
7f135263a9 ldap: add check_connection function
this function checks if a given connection could work. it uses the
current config to connect to an ldap directory and perform a search
with the provided base_dn. this enables us to verify a connection
before storing it in a more meaningful way than with a regex.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-06-26 14:15:35 +02:00
Stefan Sterz
599a6a49da ldap: remove support for unauthenticated binds
by using the default empty string if no password was provided,
unauthenticated binds were possible. to bring pbs in-line with pve,
switch to throwing an error in this case instead. however, this will
break any pre-existing setup that relied on this behavior.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-06-26 14:15:33 +02:00
Wolfgang Bumiller
962ce920a0 bump proxmox-human-byte to 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 13:37:29 +02:00
Wolfgang Bumiller
c611afcf0d human-byte: update copyright format
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 13:37:29 +02:00
Lukas Wagner
77dbc2fe18 human-byte: move tests to their sub module
The `#[cfg(test)]` directive ensures that the tests are not compiled
for non-test builds.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-06-26 13:24:51 +02:00