Commit Graph

3410 Commits

Author SHA1 Message Date
Shannon Sterz
f137b5e528 login: make password optional when creating Login requests
in certain context (for example, the browser), no password needs to be
provided when using HttpOnly cookies as they are handle by said
context. so make renewing ticket with password optional and add a new
helper function that does not require a password.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
9c6d6b8d2a login: add optional field for ticket_info and make password optional
tickets created through the new HttpOnly ticket endpoint won't return
a ticket in the password field. so this field will be left empty.
hence make it optional.

the endpoint does return a ticket_info parameter, though, that
includes the information when a ticket needs to be refreshed. so add
a new optional field for that too.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
1b9def4736 auth-api: add logout method
adds a new endpoint that is useful when dealing with HttpOnly cookies
that cannot be removed by client-side javascript (and by extension
wasm) code. the logout handle simply removes the cookie that is used
for storing the current ticket. this works the same way as it does in
the front-end: by setting an expired cookie with the same name.

as cookies are now prefixed with `__Host-` by default, the cookie here
also needs to be `Secure` and have the same `Path` to not be rejected
by the browser before it can remove the old cookie.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
6a7f631709 auth-api: make regular ticket endpoint use the new types and handler
so we can re-use more code between the different ticket endpoints

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
8405154c6d auth-api: add endpoint for issuing tickets as HttpOnly tickets
this adds a new endpoint for requesting tickets. instead of returning
the ticket in the responses body, the ticket is set as a HttpOnly
cookie. this has a couple of advantages:

- the cookie cannot be stolen if an attacker downgrades the connection
  to http and injects malicious javascript (`HttpOnly`)
- we don't need to rely on the client to make sure that the cookie is
  only send in the appropriate context and only over https
  connections (`Secure`, `SameSite`).
- the cookie cannot be overwritten by other subdomains, insecure
  connections etc. (the default is to prefix them with `__Host-`)

this follows the best practice guide for secure cookies from MDN
[1]. we also set the cookies to expire when the ticket would so that
the browser removes the cookie once the ticket isn't valid anymore.

the endpoint still returns a ticket that only contains the
informational portions of the ticket but not a valid signature. this
is helpful to let clients know when to refresh the ticket by querying
this endpoint again. it still protects the cookie, though, as it
isn't a valid ticket by itself.

[1]: https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/Cookies

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
acaffffaf9 auth-api: introduce new CreateTicket and CreateTickeReponse api types
these types are used for creating a ticket and responding to a new
ticket request.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
6f61b991a0 auth-api: check for new prefixed cookies as well
this makes sure that newly generated cookies that are prefixed with,
for example, `__Host-`, for security purposes, are correctly picked
up on. otherwise, the new cookies would not be able to yield proper
authentication.

currently this still falls back to insecure non-prefixed cookies. we
should deprecate them in the long-term and remove this fallback.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
b598e03287 auth-api: extend AuthContext with prefixed cookie name
this adds the function `prefixed_auth_cookie_name` to the
`AuthContext` trait. said function can be used by users of this crate
to modify the expected prefix of the auth cookie. most products
should be able to use the default of `__Host-` though, so this also
adds a default implementation.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
1f58e40f3f router/rest-server: add new AsyncHttpBodyParameters api handler type
this allows us to write api handlers that have access to a request's
headers and to create a low level response while being able to also
specify the parameter in the request's body. this is useful for
endpoints that should not use url parameters, but still need to
access/set specific headers.

previously, `AsyncHttp` did not allow for parameters that were marked
as non-optional to be passed in the body of a request.

as a side-effect, the body is parsed by the rest server to check for
parameters and consumed. so it cannot be passed on by the handler.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
b1ed231ed2 rest-server: borrow parts parameter in get_request_parameter
this function does not require ownership of the parts parameter, so we
can simply borrow it. this way we can pass the parameter on to a
handler that consumes them even when using `get_request_parameter`

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Shannon Sterz
316fe71133 time: add new epoch_to_http_date helper
this makes it easy to generate RFC9110 preferred HTTP Dates.

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
2025-03-04 15:53:29 +01:00
Dietmar Maurer
68b1396553 router: docs: add horizontal line before nested command docs
Lines before commanmd groups are missing (i.e. see proxmox-backup-client command
syntax docs)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-02-21 10:05:46 +01:00
Christian Ebner
29c1ceefd5 pbs api types: relax influx organization and bucket length
Relax the length limit for organization and bucket name for InfluxDB
metric servers in Proxmox Backup Server.

Commit 57fa20406 ("pbs-api-types: add metrics api types") introduced
the api schema definition for InfluxDB metric servers, limiting the
name of the organization and the name of the bucket to a length of 3,
most likely as a result of reusing the same values as for the
corresponding config id schema restrictions.

This is however not enforced by the InfluxDB REST api [0, 1] and
stricter than what is defined in Proxmox VE [2].

Reported in the community forum [3].

[0] https://docs.influxdata.com/influxdb/v2/api/#operation/PostOrgs
[1] https://docs.influxdata.com/influxdb/v2/api/#operation/PostBuckets
[2] https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/Status/InfluxDB.pm;h=13a96711e766e2f1ea71424ed6d9d8ec8450504c;hb=HEAD#l24
[3] https://forum.proxmox.com/threads/162521/

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2025-02-20 16:11:50 +01:00
Wolfgang Bumiller
052d84ef37 schema: drop useless doc comment
(it's on the wrong function, and also it's wrong - std's str
comparison forwards to the byte comparison anyway since this is fine
for utf-8 if we're not doing anything natural-language-aware...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-20 10:07:08 +01:00
Wolfgang Bumiller
ce54bd1b11 schema: verify object fields/variants are sorted and unique
This verifies *at compile time* that the properties and variants of
ObjectSchemas and OneOfSchemas are sorted.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 13:02:18 +01:00
Wolfgang Bumiller
59a9ddbf06 schema: add const-fn helper to compare strings
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 13:02:18 +01:00
Wolfgang Bumiller
e3286d3758 notify: bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 13:02:00 +01:00
Wolfgang Bumiller
ad3657011e notify: bump to 0.5.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 13:00:56 +01:00
Wolfgang Bumiller
ef54afe65f api-macro: bump to 1.3.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 12:55:38 +01:00
Wolfgang Bumiller
a36f0f3bf9 api-macro: enums: sort OneOf variants
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 12:53:46 +01:00
Wolfgang Bumiller
d38ce91384 notify: fix dummy user schema property ordering
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-02-19 12:53:46 +01:00
Lukas Wagner
0f1b84e93c sys: fs: derive Copy for CreateOptions
Pretty much all functions accepting `CreateOptions` take a value and not
a reference, so I've found myself using `.clone()` quite often in code
I've written recently.
The struct is only 24 bytes large (verified by a
`std::mem::size_of::<CreateOptions>()`), so it should be absolutely fine
to just derive Copy for it.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2025-01-29 18:09:24 +01:00
Thomas Lamprecht
31ae72ba6a schema: property ReST docs: correctly separate nested list from parent
This fixes the reStructuredText (ReST) output for more complex formats
where we got, for example, a definition list of all properties of a
(section) configuration with one or more properties then having a
sub-format that is also rendered as a list.

Such nested lists are possible in ReST but need to be separated by a
blank line [0].

Without this we got quite a few warnings/errors from the Sphinx/ReST
buildsystem looking like:

> config/datastore/config.rst:19: ERROR: Unexpected indentation.
> config/datastore/config.rst:20: WARNING: Block quote ends without a blank line; unexpected unindent.

[0]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#lists-and-quote-like-blocks

Reported-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-28 14:25:21 +01:00
Thomas Lamprecht
c0641c6e13 schema: use inline named params in format macro calls
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-28 14:25:21 +01:00
Wolfgang Bumiller
703c2dee04 api-macro: mark parameter defaults as #[allow(dead_code)]
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-28 10:56:28 +01:00
Laurențiu Leahu-Vlăducu
922c605d69 rest-server: Improved panic errors with formatted strings
Improved errors when panics occur and the panic message is a
formatted (not static) string. This worked already for &str literals,
but not for Strings.

Downcasting to both &str and String is also done by the Rust Standard
Library in the default panic handler. See:
b605c65b6e/library/std/src/panicking.rs (L777)

Signed-off-by: Laurențiu Leahu-Vlăducu <l.leahu-vladucu@proxmox.com>
2025-01-27 15:12:59 +01:00
Dietmar Maurer
f639695c87 pbs-api-types: add debian/control to git repository
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-22 12:33:33 +01:00
Dietmar Maurer
57b0477657 pbs-api-type: add as workspace member with correct debian files
Also changed the version to 0.2.0

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2025-01-22 11:57:00 +01:00
Thomas Lamprecht
b7b00b5205 Merge remote-tracking branch 'prepare-pbs-api-types-for-move/prepare-pbs-api-types-for-move'
Move over the whole history of pbs-api-types from the proxmox-backup
git repo to the common workspace as we want to re-use that in PDM and
the yew UI components, and thus require a real source-code package for
this crate.

Choose this repo over proxmox-api-types to avoid the need to copy this
build-system over there, rather we want to also merge pve-api-types
from that repo into ours here in the future.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-22 11:55:09 +01:00
Thomas Lamprecht
0477adaf88 client: fix code-style issue when formatting error
Fixes a style issue introduced by b31ab119 ("client: improve api error
message (avoid duplicate status code)"), as one always should use
inline variables for format template strings even if there are some
that cannot be used, e.g. as some method needs to be called on them
like here. The reason for this is to reduce the amount of
free-standing "{}" and parameters as that reduces the need to manually
match what "{}" resolves to which expression. While it is not that bad
for only two format variables it's still not winning us anything if we
don't do it and breaks consistency with newer code style.

Noticed as that commit made the line overly long, causing rustfmt
changing the line.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-21 09:22:08 +01:00
Thomas Lamprecht
daff73bdd6 sys: use correct pointer type for mkdtemp return value
The libc function mkdtemp takes a C char pointer while we previously
cast our OSString buffer as i8 pointer, but that's not valid on
platforms like AArch64 (ARM), where char is equivalent with a u8.

Fix that by using the c_char type that was explicitly made to always
get the correct, platform-independent type for C chars when doing FFI.

This was reported by OJaksch on our Arch Linux User Repo (AUR) package
[0].

https://aur.archlinux.org/packages/proxmox-backup-client#comment-1006851

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-01-21 09:14:43 +01:00
Wolfgang Bumiller
5a7993beb0 update to proxmox-schema 4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 13:03:42 +01:00
Wolfgang Bumiller
4be2392d59 time-api: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:54:28 +01:00
Wolfgang Bumiller
e0bdcda6e6 syslog-api: bump to 0.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:53:28 +01:00
Wolfgang Bumiller
27c50bd037 rrd-api-types: bump to 1.0.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:52:15 +01:00
Wolfgang Bumiller
975f29bd7f network-api: bump to 0.1.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:51:19 +01:00
Wolfgang Bumiller
ce206f0a96 dns-api: bump to 0.1.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:50:26 +01:00
Wolfgang Bumiller
891413ffb7 access-control: bump to 0.2.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:49:23 +01:00
Wolfgang Bumiller
f01f934963 auth-api: bump to 0.4.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:47:08 +01:00
Wolfgang Bumiller
0807248c15 acme-api: bump to 0.1.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:46:13 +01:00
Wolfgang Bumiller
7e25958623 tfa: bump to 5.0.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:43:41 +01:00
Wolfgang Bumiller
40f0a0bdd3 subscription: bump to 0.5.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:42:10 +01:00
Wolfgang Bumiller
c84376e2c8 apt: bump to 0.11.7-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:40:14 +01:00
Wolfgang Bumiller
5382b8ce13 apt-api-types: bump to 1.0.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:38:33 +01:00
Wolfgang Bumiller
ca92328569 api-macro: bump to 1.3.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:36:57 +01:00
Wolfgang Bumiller
59d1ca87e5 rrd: bump to 0.4.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:36:56 +01:00
Wolfgang Bumiller
106aa95ced rest-server: bump to 0.8.6-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:35:43 +01:00
Wolfgang Bumiller
698b6782cd router: bump to 3.0.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:35:43 +01:00
Wolfgang Bumiller
69298c8d20 acme: bump to 0.5.4-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:28:06 +01:00
Wolfgang Bumiller
ed74a6a8a2 simple-config: bump to 0.1.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-01-15 12:26:42 +01:00