Commit Graph

2177 Commits

Author SHA1 Message Date
Dietmar Maurer
6b59158aaf proxmox-rest-server: return status code with ExtJsFormatter
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-28 11:29:35 +01:00
Wolfgang Bumiller
3932e5bedf bump proxmox-auth-api to 0.3.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-27 14:46:59 +01:00
Wolfgang Bumiller
4a8cadc7e0 bump proxmox-rest-server to 0.5.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-27 14:39:22 +01:00
Max Carrara
7d29269986 rest-server: Add Redirector
The `Redirector` is a simple `Service` that redirects HTTP requests
to HTTPS and can be served by a `hyper::Server`.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-27 14:28:18 +01:00
Max Carrara
57b4c4624b rest-server: Refactor AcceptBuilder, provide support for optional TLS
The new public function `accept_tls_optional()` is added, which
accepts both plain TCP streams and TCP streams running TLS. Plain TCP
streams are sent along via a separate channel in order to clearly
distinguish between "secure" and "insecure" connections.

Furthermore, instead of `AcceptBuilder` itself holding a reference to
an `SslAcceptor`, its public functions now take the acceptor as an
argument. The public functions' names are changed to distinguish
between their functionality in a more explicit manner:

  * `accept()` --> `accept_tls()`
  *        NEW --> `accept_tls_optional()`

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-27 14:28:15 +01:00
Fabian Grünbichler
8eff15b0b0 subscription: update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-27 14:08:18 +01:00
Fabian Grünbichler
eadf2e06c3 bump proxmox-subscription to 0.4.2-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-27 13:59:40 +01:00
Stefan Sterz
ee7a908ebc subscription: expose the next_due_date as an i64
internally `SubscriptionInfo` already uses the `parse_next_due` helper
to parse the next due date to an epoch. this exposes a function that
allows us to use the epoch outside of this crate too. for example, a
user of pom may have multiple subscription for the same system. in
that case we want to apply the one with the due date that is furthest
in the future.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-11-27 13:59:40 +01:00
Fabian Grünbichler
81cdba6181 subscription: let ProductType derive Hash
for usage in HashMap keys

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-11-27 13:59:40 +01:00
Stefan Sterz
82e742f8f5 type: move ProductType type to proxmox-subscription from pom
previously this type lived inside of pom. this made it harder to
access the product type from a `SubscriptionInfo` trait in other
products. move the type here so we can check product types more
consistently across products (e. g. in pom and pbs)

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-11-27 13:31:59 +01:00
Wolfgang Bumiller
4da2fee6fa bump tfa to 4.1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-23 09:21:38 +01:00
Wolfgang Bumiller
74c3943a89 bump schema to 2.0.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-23 09:16:46 +01:00
Dietmar Maurer
578f994e6b proxmox-schema: derive PartialEq for UPID (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-11-20 11:10:22 +01:00
Thomas Lamprecht
eb6df88120 notify: bump version to 0.3.0-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 13:36:55 +01:00
Thomas Lamprecht
af660f1fee sys: bump version to 0.5.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 10:42:38 +01:00
Thomas Lamprecht
ca76122b16 notify: update d/control
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 08:37:36 +01:00
Thomas Lamprecht
a3fbe14f44 sys: purge pty module
it was only used in the terminal proxy and got moved there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 08:35:18 +01:00
Lukas Wagner
9bea76c6b9 notify: add built-in config and 'origin' parameter
This allows us to define a (modifiable) builtin-config, which is
at the moment hardcoded in PVEContext

The 'origin' parameter indicates whether a config entry was created by
a user, builtin or a modified builtin.

These changes require context to be set for tests, so we set
PVEContext by default if in a test context. There might be a nicer
solution for that, but for now this should work.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
306f4005a1 notify: add 'disable' parameter for matchers and targets.
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
20b290893a notify: add api for smtp endpoints
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
53627a1952 notify: add 'smtp' endpoint
This commit adds a new endpoint type, namely 'smtp'. This endpoint
uses the `lettre` crate to directly send emails to SMTP relays.

The `lettre` crate was chosen since it is by far the most popular SMTP
implementation for Rust that looks like it is well maintained.
Also, it includes async support (for when we want to extend
proxmox-notify to be async).

For this new endpoint type, a new section-config type was introduced
(smtp). It has the same fields as the type for `sendmail`, with the
addition of some new options (smtp server, authentication, tls mode,
etc.).

Some of the behavior that is shared between sendmail and smtp
endpoints has been moved to a new `endpoints::common::mail` module.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
c1a3505e51 notify: add PVE/PBS context
This commit moves PVEContext from `proxmox-perl-rs` into the
`proxmox-notify` crate, since we now also need to access it from
`promxox-mail-forward`. The context is now hidden behind a feature
flag `pve-context`, ensuring that we only compile it when needed.

This commit adds PBSContext, since we now require it for
`proxmox-mail-forward`. Some of the code for PBSContext comes
from `proxmox-mail-forward`.

This commit also changes the global context from being stored in a
`once_cell` to a regular `Mutex`, since we now need to set/reset
the context in `proxmox-mail-forward`.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
5f7ac875f6 notify: add mechanisms for email message forwarding
As preparation for the integration of `proxmox-mail-foward` into the
notification system, this commit makes a few changes that allow us to
forward raw email messages (as passed from postfix).

For mail-based notification targets, the email will be forwarded
as-is, including all headers. The only thing that changes is the
message envelope.
For other notification targets, the mail is parsed using the
`mail-parser` crate, which allows us to extract a subject and a body.
As a body we use the plain-text version of the mail. If an email is
HTML-only, the `mail-parser` crate will automatically attempt to
transform the HTML into readable plain text.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
d20d9ec1aa sys: email: add forward
This new function forwards an email to new recipients.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
80c9069389 notify: let a matcher always match if it has no matching directives
This should be a bit more intuitive to users than the current
behavior, which is 'always match' for mode==all and 'never match' for
mode==any. The current behavior originates in the neutral element of
the underlying logical operation (and, or).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
190d483b2d notify: matcher: introduce common trait for match directives
This allows us to make the match-checking code a bit shorter.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
bdbd55ccff notify: add calendar matcher
This allows matching by a notification's timestamp:

matcher: foo
  match-calendar mon..fri 8-12

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
b421a7ca24 notify: replace filters and groups with matcher-based system
This shifts notification routing into the matcher-system. Every
notification has associated metadata (key-value fields, severity -
to be extended) that can be match with match directives in
notification matchers. Right now, there are 2 matching directives,
match-field and match-severity. The first one allows one to do a
regex match/exact match on a metadata field, the other one allows one
to match one or more severites.
Every matcher also allows 'target' directives, these decide which
target(s) will be notified if a matcher matches a notification.

Since routing now happens in matchers, the API for sending is
simplified, since we do not need to specify a target any more.

The API routes for filters and groups have been removed completely.
The parser for the configuration file will still accept filter/group
entries, but will delete them once the config is saved again. This is
needed to allow a smooth transition from the old system to the new
system, since the old system was already available on pvetest.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
df4858e989 notify: factor out notification content into its own type
This will be useful later for system mail forwarding, where
the content of the mail should be forwarded unchanged.

This moves notification properties into this new type and calls them
'data'. They will exclusively used for template rendering.
`Notification` will receive a separate field for metadata, which
will be useful for notification filtering. This decouples
template rendering and filtering, which enables us to be very precise
about which metadata fields we allow to be used in filters.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
b2089c37c5 notify: introduce Error::Generic
... as leaf error-type for anything for which we do not necessarily
want a separate enum variant.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Lukas Wagner
3ac6f2d9c0 http: rate limited stream: fix typo in rustdoc comment
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-08 09:56:26 +01:00
Fiona Ebner
f844271990 apt: repositories: document status property for standard repository
Suggested-by: Dietmar Maurer <dietmar@proxmox.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-11-06 19:48:30 +01:00
Thomas Lamprecht
69edfdf985 rest-server: parse upid: improve on comments and variables
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-26 10:41:15 +02:00
Thomas Lamprecht
06fed255cb rest-server: extend documentation for reading status of a UPID
Including some possible pitfalls when using this.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-26 10:26:11 +02:00
Thomas Lamprecht
ba59b84d46 rest-server: code complexity clean-up in task-log rotation
avoid using the negative in the if check and extract the value to be
passed upfront.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-26 10:13:45 +02:00
Thomas Lamprecht
4197e94e25 rest-server: better document task-log archive rotation
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-26 10:13:45 +02:00
Thomas Lamprecht
c8a0ba04ca sys: depreacate PTY module, moves to termproxy directly
As termproxy only used this module from the huge proxmox-sys crate,
and this module was also only used here, it makes sense to move it
over there (and dropping proxmox-sys halved build-time from 8.5 s to
4.2 s).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-24 13:52:16 +02:00
Gabriel Goller
c1c062bf56 schema: beautify parameter error output
If there is only one error, output in a single line, without any
excessive newlines at the end. If there are multiple errors, show them
in a bulleted list.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2023-10-23 17:40:34 +02:00
Dietmar Maurer
34e86078c2 proxmox-tfa: derive Copy, Clone and PartialEq on TfaType (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-23 11:44:45 +02:00
Dietmar Maurer
c1819c2549 DailyDuration: derive PartialEq (for GUI)
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-20 12:01:27 +02:00
Thomas Lamprecht
1e64feeaad rest-server: factor out task-log directory and creation
We had two call sites deriving the directory "shard" where the task
log file is actually saved to, this can lead to ugly bugs and is
better done in a central single-source-of-truth way.

While at it factor out the creation of the log file (and it's shard
directory) to avoid crowding the WorkerTask new fn to much.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-18 19:36:37 +02:00
Wolfgang Bumiller
45152c5e3e bump proxmox-client to 0.3.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 13:27:13 +02:00
Wolfgang Bumiller
2c9c43ca4c human-byte: d/control bump
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 13:04:48 +02:00
Wolfgang Bumiller
f47ad56812 bump proxmox-human-byte to 0.1.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 13:03:12 +02:00
Dietmar Maurer
83af1cdce4 HumanByte: make fields public
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2023-10-16 12:27:54 +02:00
Wolfgang Bumiller
9e8f90e667 tfa: more optional dependency cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 09:00:18 +02:00
Wolfgang Bumiller
6940908a8a tfa: make totp a feature and mark all optional deps as optional
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 08:58:09 +02:00
Wolfgang Bumiller
1a6f1efe63 workspace: set resolver to 2 to silence a warning
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-10-16 08:53:35 +02:00
Fabian Grünbichler
04e2d0e5c3 bump proxmox-api-macro to 1.0.6-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-10-03 09:37:01 +02:00
Fabian Grünbichler
c83627b1a6 bump proxmox-sortable-macro to 0.1.3-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-10-03 09:37:01 +02:00