]> git.proxmox.com Git - proxmox.git/log
proxmox.git
10 months agoclient: put requests
Wolfgang Bumiller [Wed, 9 Aug 2023 12:53:39 +0000 (14:53 +0200)]
client: put requests

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: handle response data
Wolfgang Bumiller [Tue, 8 Aug 2023 14:52:11 +0000 (16:52 +0200)]
client: handle response data

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: turn Client inside out
Wolfgang Bumiller [Tue, 8 Aug 2023 09:03:58 +0000 (11:03 +0200)]
client: turn Client inside out

Since the WASM client cannot actually use a `http::Request` the way we
expect it to, that is, it cannot manually along cookies, we turn the
client bit inside out:

This crate mainly defines the `HttpApiClient` trait which expects the
http client to perform *authenticated* API calls, that is, the
handling of API tokens and tickets should happen at the *implementor*
side.

The product clients will require *this* trait to be implemented, and
will not themselves offer a way to login.

As for the `Client` struct, this will now instead *implement* this
trait and will *not* be used in the `wasm` ecosystem. Rather, this is
the ticket handling http client that already exists in the PWT based
ui code.

The PVE client in `pve-api-types` will not *contain* a `Client`
anymore, but rather, it will provide PVE api call implementations for
something implementing `HttpApiClient`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: drop environment and login methods
Wolfgang Bumiller [Mon, 7 Aug 2023 12:25:25 +0000 (14:25 +0200)]
client: drop environment and login methods

The environment trait was useful on the CLI, but does not really
translate well to eg. the wasm ui (or pdm for that matter), so drop it
and instead have `.login` and `.login_tfa` just take the
`proxmox_login` type and handle the updating of authentication data.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: replace Error trait with a type
Wolfgang Bumiller [Mon, 7 Aug 2023 09:55:59 +0000 (11:55 +0200)]
client: replace Error trait with a type

Because we ultimately also want to drop the `Environment` trait since
it is not suitable for all use cases (eg. wasm ui)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: prepare to get rid of Error trait
Wolfgang Bumiller [Mon, 7 Aug 2023 09:19:39 +0000 (11:19 +0200)]
client: prepare to get rid of Error trait

First rename it so it's clear what "Error" refers to in the following
patches.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agologin: add userid and api_url getters
Wolfgang Bumiller [Mon, 7 Aug 2023 09:16:36 +0000 (11:16 +0200)]
login: add userid and api_url getters

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoproxmox-io: fix `sparse_copy` not copying sparsely on irregular read operations
Max Carrara [Mon, 17 Jul 2023 14:19:40 +0000 (16:19 +0200)]
proxmox-io: fix `sparse_copy` not copying sparsely on irregular read operations

In the uncommon circumstance that calls to `read()` end up reading any number of
bytes other than 4096, the subsequently read bytes become misaligned, causing
blocks of zeroes to be written unnecessarily.

To illustrate, imagine you have a 12KiB file:

  [x][x][x][x][ ][ ][ ][ ][x][x][x][x]
   └──4096──┘  └──4096──┘  └──4096──┘

The first and last block are filled with some data, whereas the middle block is
empty and will therefore result in only zeroes being read.

In order for the empty block to be skipped with `seek()`, the entire buffer has
to be filled with zeroes.

If, for example, the first `read()` ends up putting only 3KiB into the buffer,
the empty block in the middle won't be detected properly, as the buffer will
now always contain some data. What results are four misaligned reads:

  [x][x][x][x][ ][ ][ ][ ][x][x][x][x]
   ├─────┘  ├────────┘  ├────────┘  │
   1        2           3           4

This is fixed by ensuring chunks of 4KiB are always read into the buffer,
except when the last block is truncated. In order to prevent frequent small
reads, the incoming reader is also buffered via `io::BufReader`.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
10 months agobump proxmox-ldap to 0.2.1-1
Wolfgang Bumiller [Tue, 8 Aug 2023 12:08:47 +0000 (14:08 +0200)]
bump proxmox-ldap to 0.2.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agobump proxmox-apt to 0.10.5-1
Wolfgang Bumiller [Tue, 8 Aug 2023 12:05:51 +0000 (14:05 +0200)]
bump proxmox-apt to 0.10.5-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoldap: only search base of base_dn when checking connection
Stefan Sterz [Fri, 21 Jul 2023 14:34:03 +0000 (16:34 +0200)]
ldap: only search base of base_dn when checking connection

this should avoid most common size limitations. the search should also
complete quicker as fewer results need to be computed. note that this
way a configuration may be accepted, but the related sync job can
fail due to and exceeded size limit warning for some ldap servers
(such as 2.5.14+dfsg-0ubuntu0.22.04.2).

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
10 months agoldap: add an integration test for `check_connection`
Stefan Sterz [Fri, 21 Jul 2023 14:34:02 +0000 (16:34 +0200)]
ldap: add an integration test for `check_connection`

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
10 months agofix #4868: map missing section field to 'unknown'
Fabian Grünbichler [Tue, 25 Jul 2023 08:31:10 +0000 (10:31 +0200)]
fix #4868: map missing section field to 'unknown'

needed for supporting some third-party repositories.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
10 months agoclippy fix: casting to the same type is unnecessary
Lukas Wagner [Tue, 8 Aug 2023 09:44:54 +0000 (11:44 +0200)]
clippy fix: casting to the same type is unnecessary

See: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: deref on an immutable reference
Lukas Wagner [Tue, 8 Aug 2023 08:01:53 +0000 (10:01 +0200)]
clippy fix: deref on an immutable reference

See:
https://rust-lang.github.io/rust-clippy/master/index.html#borrow_deref_ref

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: complex type definitions
Lukas Wagner [Tue, 8 Aug 2023 08:01:52 +0000 (10:01 +0200)]
clippy fix: complex type definitions

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: the following explicit lifetimes could be elided
Lukas Wagner [Tue, 8 Aug 2023 08:01:51 +0000 (10:01 +0200)]
clippy fix: the following explicit lifetimes could be elided

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: useless use of `format!`
Lukas Wagner [Tue, 8 Aug 2023 08:01:50 +0000 (10:01 +0200)]
clippy fix: useless use of `format!`

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: warning: this let-binding has unit value
Lukas Wagner [Tue, 8 Aug 2023 08:01:49 +0000 (10:01 +0200)]
clippy fix: warning: this let-binding has unit value

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: binary comparison to literal `Option::None`
Lukas Wagner [Tue, 8 Aug 2023 08:01:48 +0000 (10:01 +0200)]
clippy fix: binary comparison to literal `Option::None`

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: unnecessary use of `to_string`
Lukas Wagner [Tue, 8 Aug 2023 08:01:47 +0000 (10:01 +0200)]
clippy fix: unnecessary use of `to_string`

See:
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_to_owned

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: you should consider adding a `Default` implementation
Lukas Wagner [Tue, 8 Aug 2023 08:01:46 +0000 (10:01 +0200)]
clippy fix: you should consider adding a `Default` implementation

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: this (Default) `impl` can be derived
Lukas Wagner [Tue, 8 Aug 2023 08:01:45 +0000 (10:01 +0200)]
clippy fix: this (Default) `impl` can be derived

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: redundant closure
Lukas Wagner [Tue, 8 Aug 2023 08:01:44 +0000 (10:01 +0200)]
clippy fix: redundant closure

See:
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: unneeded `return` statement
Lukas Wagner [Tue, 8 Aug 2023 08:01:43 +0000 (10:01 +0200)]
clippy fix: unneeded `return` statement

See:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: needless borrow
Lukas Wagner [Tue, 8 Aug 2023 08:01:42 +0000 (10:01 +0200)]
clippy fix: needless borrow

See:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: calls to `drop` with a value that implements `Copy`
Lukas Wagner [Tue, 8 Aug 2023 08:01:41 +0000 (10:01 +0200)]
clippy fix: calls to `drop` with a value that implements `Copy`

Dropping a copy leaves the original intact

See:
https://rust-lang.github.io/rust-clippy/master/index.html#drop_copy

I assume the `drop` was used to silence a 'unused variable' warning,
so I silenced it by other means.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoclippy fix: the borrowed expression implements the required traits
Lukas Wagner [Tue, 8 Aug 2023 08:01:39 +0000 (10:01 +0200)]
clippy fix: the borrowed expression implements the required traits

See: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agoproxmox-login: depend on js_sys on wasm32
Dietmar Maurer [Mon, 7 Aug 2023 10:01:37 +0000 (12:01 +0200)]
proxmox-login: depend on js_sys on wasm32

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
10 months agoadd special impl for epoch_i64() on target_arch="wasm32"
Dietmar Maurer [Mon, 7 Aug 2023 09:54:02 +0000 (11:54 +0200)]
add special impl for epoch_i64() on target_arch="wasm32"

10 months agoclient: drop Send for non-wasm as well on response future
Wolfgang Bumiller [Mon, 7 Aug 2023 09:04:50 +0000 (11:04 +0200)]
client: drop Send for non-wasm as well on response future

To see if it is even still necessary given that it's not a trait
object type where auto traits would need to be explicit...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: rename response future to ResponseFuture
Wolfgang Bumiller [Mon, 7 Aug 2023 08:58:24 +0000 (10:58 +0200)]
client: rename response future to ResponseFuture

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: drop retry logic
Wolfgang Bumiller [Mon, 7 Aug 2023 08:57:38 +0000 (10:57 +0200)]
client: drop retry logic

This should be moved to where we actually need it, not be part of the
generic product client.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoproxmox-client: do not require Send for wasm32 target
Dietmar Maurer [Sat, 5 Aug 2023 07:09:48 +0000 (09:09 +0200)]
proxmox-client: do not require Send for wasm32 target

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
10 months agoproxmox-login: add 'source' impls for errors
Wolfgang Bumiller [Thu, 3 Aug 2023 09:06:33 +0000 (11:06 +0200)]
proxmox-login: add 'source' impls for errors

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agobump proxmox-api-macro to 1.0.5-1
Wolfgang Bumiller [Thu, 3 Aug 2023 06:24:42 +0000 (08:24 +0200)]
bump proxmox-api-macro to 1.0.5-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoclient: getters for the inner client
Wolfgang Bumiller [Thu, 3 Aug 2023 06:22:42 +0000 (08:22 +0200)]
client: getters for the inner client

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoproxmox-login: fix ticket userid check for PMG quarantine tickets
Dietmar Maurer [Wed, 2 Aug 2023 12:30:04 +0000 (14:30 +0200)]
proxmox-login: fix ticket userid check for PMG quarantine tickets

We simply strip the "@quarantine" at the end.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
10 months agoimport proxmox-client crate
Wolfgang Bumiller [Tue, 1 Aug 2023 13:47:13 +0000 (15:47 +0200)]
import proxmox-client crate

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agoupdate README
Wolfgang Bumiller [Tue, 1 Aug 2023 13:47:20 +0000 (15:47 +0200)]
update README

include repository.workspace=true for the [package] base section

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agologin: improve response handling
Wolfgang Bumiller [Tue, 1 Aug 2023 13:16:07 +0000 (15:16 +0200)]
login: improve response handling

we have use cases where we have bytes, and serde_json has a from_slice
method, doing the utf-8 check unnecessarily is pointless, while going
from &str to &[u8] is free...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agobump proxmox-notify to 0.2.0
Wolfgang Bumiller [Fri, 28 Jul 2023 09:33:13 +0000 (11:33 +0200)]
bump proxmox-notify to 0.2.0

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agomore import cleanups
Wolfgang Bumiller [Fri, 28 Jul 2023 09:47:09 +0000 (11:47 +0200)]
more import cleanups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agonotify: cleanup all the imports sections
Wolfgang Bumiller [Fri, 28 Jul 2023 09:42:26 +0000 (11:42 +0200)]
notify: cleanup all the imports sections

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agobump proxmox-router to 2.1.0-1
Wolfgang Bumiller [Fri, 28 Jul 2023 09:26:01 +0000 (11:26 +0200)]
bump proxmox-router to 2.1.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agohttp-error: add debian packaging and bump as 0.1.0-1
Wolfgang Bumiller [Fri, 28 Jul 2023 09:06:03 +0000 (11:06 +0200)]
http-error: add debian packaging and bump as 0.1.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
10 months agonotify: use HttpError from proxmox-http-error
Lukas Wagner [Wed, 26 Jul 2023 14:18:23 +0000 (16:18 +0200)]
notify: use HttpError from proxmox-http-error

Also improve API documentation in terms of which HttpError is
returned when.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agorouter: re-export `HttpError` from `proxmox-http-error`
Lukas Wagner [Wed, 26 Jul 2023 14:18:22 +0000 (16:18 +0200)]
router: re-export `HttpError` from `proxmox-http-error`

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agohttp-error: add new http-error crate
Lukas Wagner [Wed, 26 Jul 2023 14:18:21 +0000 (16:18 +0200)]
http-error: add new http-error crate

Break out proxmox-router's HttpError into it's own crate so that it can
be used without pulling in proxmox-router.

This commit also implements `Serialize` for `HttpError` so that it can
be returned from perlmod bindings, allowing Perl code to access the
status code as well as the message.

Also add some smoke-tests to make sure that the `http_bail` and
`http_err` macros actually produce valid code.

Suggested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agonotify: fix tests if not all features are enabled
Lukas Wagner [Mon, 24 Jul 2023 12:31:25 +0000 (14:31 +0200)]
notify: fix tests if not all features are enabled

Some tests are now disabled if not all required features are enabled.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
10 months agonotify: fix build warnings if not all features are enabled
Lukas Wagner [Mon, 24 Jul 2023 12:31:24 +0000 (14:31 +0200)]
notify: fix build warnings if not all features are enabled

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agobump proxmox-notify to 0.1.0-1, initial release
Wolfgang Bumiller [Mon, 24 Jul 2023 09:05:02 +0000 (11:05 +0200)]
bump proxmox-notify to 0.1.0-1, initial release

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-auth-api to 0.3.1
Wolfgang Bumiller [Mon, 24 Jul 2023 09:03:25 +0000 (11:03 +0200)]
bump proxmox-auth-api to 0.3.1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-section-config to 2.0.0-1
Wolfgang Bumiller [Mon, 24 Jul 2023 09:00:43 +0000 (11:00 +0200)]
bump proxmox-section-config to 2.0.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-subscription to 0.4.1-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:57:26 +0000 (10:57 +0200)]
bump proxmox-subscription to 0.4.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-tfa to 4.0.5
Wolfgang Bumiller [Mon, 24 Jul 2023 08:55:55 +0000 (10:55 +0200)]
bump proxmox-tfa to 4.0.5

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-rest-server to 0.4.2-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:52:27 +0000 (10:52 +0200)]
bump proxmox-rest-server to 0.4.2-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-apt to 0.10.4-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:48:36 +0000 (10:48 +0200)]
bump proxmox-apt to 0.10.4-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-human-byte to 0.1.1-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:46:39 +0000 (10:46 +0200)]
bump proxmox-human-byte to 0.1.1-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-router to 2.0.0-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:44:44 +0000 (10:44 +0200)]
bump proxmox-router to 2.0.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agobump proxmox-schema to 2.0.0-1
Wolfgang Bumiller [Mon, 24 Jul 2023 08:40:33 +0000 (10:40 +0200)]
bump proxmox-schema to 2.0.0-1

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agonotify: add debian packaging
Lukas Wagner [Thu, 20 Jul 2023 14:31:52 +0000 (16:31 +0200)]
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>
11 months agonotify: additional logging when sending a notification
Lukas Wagner [Thu, 20 Jul 2023 14:31:51 +0000 (16:31 +0200)]
notify: additional logging when sending a notification

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: ensure that filter/group/endpoint names are unique
Lukas Wagner [Thu, 20 Jul 2023 14:31:50 +0000 (16:31 +0200)]
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>
11 months agonotify: on deletion, check if a filter/endp. is still used by anything
Lukas Wagner [Thu, 20 Jul 2023 14:31:49 +0000 (16:31 +0200)]
notify: on deletion, check if a filter/endp. is still used by anything

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: api: allow to query entities referenced by filter/target
Lukas Wagner [Thu, 20 Jul 2023 14:31:48 +0000 (16:31 +0200)]
notify: api: allow to query entities referenced by filter/target

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: gotify: add proxy support
Lukas Wagner [Thu, 20 Jul 2023 14:31:47 +0000 (16:31 +0200)]
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>
11 months agonotify: sendmail: query default author/mailfrom from context
Lukas Wagner [Thu, 20 Jul 2023 14:31:46 +0000 (16:31 +0200)]
notify: sendmail: query default author/mailfrom from context

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: sendmail: allow users as recipients
Lukas Wagner [Thu, 20 Jul 2023 14:31:45 +0000 (16:31 +0200)]
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>
11 months agonotify: add context
Lukas Wagner [Thu, 20 Jul 2023 14:31:44 +0000 (16:31 +0200)]
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>
11 months agonotify: add example for template rendering
Lukas Wagner [Thu, 20 Jul 2023 14:31:43 +0000 (16:31 +0200)]
notify: add example for template rendering

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: add template rendering
Lukas Wagner [Thu, 20 Jul 2023 14:31:42 +0000 (16:31 +0200)]
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>
11 months agonotify: api: add API for filters
Lukas Wagner [Thu, 20 Jul 2023 14:31:41 +0000 (16:31 +0200)]
notify: api: add API for filters

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: add notification filter mechanism
Lukas Wagner [Thu, 20 Jul 2023 14:31:40 +0000 (16:31 +0200)]
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>
11 months agonotify: api: add API for groups
Lukas Wagner [Thu, 20 Jul 2023 14:31:39 +0000 (16:31 +0200)]
notify: api: add API for groups

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: add notification groups
Lukas Wagner [Thu, 20 Jul 2023 14:31:38 +0000 (16:31 +0200)]
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>
11 months agonotify: api: add API for gotify endpoints
Lukas Wagner [Thu, 20 Jul 2023 14:31:37 +0000 (16:31 +0200)]
notify: api: add API for gotify endpoints

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: add gotify endpoint
Lukas Wagner [Thu, 20 Jul 2023 14:31:36 +0000 (16:31 +0200)]
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>
11 months agonotify: api: add API for sendmail endpoints
Lukas Wagner [Thu, 20 Jul 2023 14:31:35 +0000 (16:31 +0200)]
notify: api: add API for sendmail endpoints

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: add sendmail plugin
Lukas Wagner [Thu, 20 Jul 2023 14:31:34 +0000 (16:31 +0200)]
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>
11 months agonotify: api: add API for sending notifications/testing endpoints
Lukas Wagner [Thu, 20 Jul 2023 14:31:33 +0000 (16:31 +0200)]
notify: api: add API for sending notifications/testing endpoints

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: preparation for the API
Lukas Wagner [Thu, 20 Jul 2023 14:31:32 +0000 (16:31 +0200)]
notify: preparation for the API

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agonotify: preparation for the first endpoint plugin
Lukas Wagner [Thu, 20 Jul 2023 14:31:31 +0000 (16:31 +0200)]
notify: preparation for the first endpoint plugin

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agoadd proxmox-notify crate
Lukas Wagner [Thu, 20 Jul 2023 14:31:30 +0000 (16:31 +0200)]
add proxmox-notify crate

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agoschema: add schema/format for comments
Lukas Wagner [Thu, 20 Jul 2023 14:31:29 +0000 (16:31 +0200)]
schema: add schema/format for comments

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agosection-config: derive Clone for SectionConfigData
Lukas Wagner [Thu, 20 Jul 2023 14:31:28 +0000 (16:31 +0200)]
section-config: derive Clone for SectionConfigData

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
11 months agoschema: verify property strings w/ new serde code
Wolfgang Bumiller [Mon, 6 Mar 2023 15:21:17 +0000 (16:21 +0100)]
schema: verify property strings w/ new serde code

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agoschema: predictable order of errors for tests
Wolfgang Bumiller [Mon, 6 Mar 2023 15:20:47 +0000 (16:20 +0100)]
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>
11 months agoschema: fixup empty error list handling
Wolfgang Bumiller [Mon, 6 Mar 2023 15:02:21 +0000 (16:02 +0100)]
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>
11 months agoschema: guard property string constraint checking
Wolfgang Bumiller [Fri, 3 Mar 2023 13:48:04 +0000 (14:48 +0100)]
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>
11 months agoschema: get rid of some unsafe code
Wolfgang Bumiller [Fri, 3 Mar 2023 13:37:01 +0000 (14:37 +0100)]
schema: get rid of some unsafe code

the borrow tracking won't hurt...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agoschema: use schema when serializing property strings
Wolfgang Bumiller [Mon, 27 Feb 2023 13:05:48 +0000 (14:05 +0100)]
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>
11 months agoschema: convenience accessors to schema subtypes
Wolfgang Bumiller [Mon, 27 Feb 2023 13:05:36 +0000 (14:05 +0100)]
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>
11 months agoschema: serde based property string de- and serialization
Wolfgang Bumiller [Wed, 15 Feb 2023 13:55:10 +0000 (14:55 +0100)]
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::de::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>
11 months agoauth-api: fixup examples
Wolfgang Bumiller [Mon, 10 Jul 2023 07:05:47 +0000 (09:05 +0200)]
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>
11 months agoproxmox-apt: bump to 0.10.3-1
Thomas Lamprecht [Thu, 29 Jun 2023 11:14:36 +0000 (13:14 +0200)]
proxmox-apt: bump to 0.10.3-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
11 months agobump proxmox-tfa to 4.0.4
Wolfgang Bumiller [Wed, 5 Jul 2023 08:43:47 +0000 (10:43 +0200)]
bump proxmox-tfa to 4.0.4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
11 months agotfa: also reset counters when unlocking tfa
Wolfgang Bumiller [Tue, 4 Jul 2023 11:23:53 +0000 (13:23 +0200)]
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>
11 months agorelease file: extend component fixup to bookworm
Fabian Grünbichler [Thu, 29 Jun 2023 10:30:03 +0000 (12:30 +0200)]
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>
12 months agoproxmox-rest-server: bump to 0.4.1-1
Thomas Lamprecht [Tue, 27 Jun 2023 10:44:52 +0000 (12:44 +0200)]
proxmox-rest-server: bump to 0.4.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>