From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 758001FF145 for ; Thu, 05 Feb 2026 15:25:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8510212A31; Thu, 5 Feb 2026 15:26:04 +0100 (CET) Content-Type: text/plain; charset=UTF-8 Date: Thu, 05 Feb 2026 15:25:59 +0100 Message-Id: Subject: Re: [PATCH datacenter-manager v1 2/4] api: acme: define API type for ACME registration parameters From: "Lukas Wagner" To: "Shan Shaji" , Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: aerc 0.21.0-0-g5549850facc2-dirty References: <20260203175101.457724-1-s.shaji@proxmox.com> <20260203175101.457724-3-s.shaji@proxmox.com> In-Reply-To: <20260203175101.457724-3-s.shaji@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1770301481672 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: W6M3GL77GZTGBUPTHIVUCLK326L6TVVG X-Message-ID-Hash: W6M3GL77GZTGBUPTHIVUCLK326L6TVVG X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue Feb 3, 2026 at 6:50 PM CET, Shan Shaji wrote: > Earlier, the ACME CLI was using the proxmox-acme-api crate's register > function to register an ACME account. Since it did not create a worker > task internally, the logs were not being recorded in the task log file. > > The API handler function accepts a Value type, inorder to pass the > parameters from the CLI it had to be converted into a Value type. > Defined a new struct to create the request parameters. This also makes > sure that even if additional parameters are added later, they > are not forgotten in the CLI tool. > > Signed-off-by: Shan Shaji > --- > > note: This is a new patch. > > lib/pdm-api-types/src/acme.rs | 65 +++++++++++++++++++++++++++++++++++ > lib/pdm-api-types/src/lib.rs | 2 ++ > server/src/api/config/acme.rs | 48 ++++++++------------------ > 3 files changed, 82 insertions(+), 33 deletions(-) > create mode 100644 lib/pdm-api-types/src/acme.rs > > diff --git a/lib/pdm-api-types/src/acme.rs b/lib/pdm-api-types/src/acme.r= s > new file mode 100644 > index 0000000..e5fc197 > --- /dev/null > +++ b/lib/pdm-api-types/src/acme.rs > @@ -0,0 +1,65 @@ > +use serde::{Deserialize, Serialize}; > + > +use proxmox_acme_api::AcmeAccountName; > +use proxmox_schema::{api, ApiStringFormat, ArraySchema, Schema, StringSc= hema}; > + > +use crate::EMAIL_SCHEMA; > + > +pub const ACME_CONTACT_LIST_SCHEMA: Schema =3D > + StringSchema::new("List of email addresses, comma seperated.") > + .format(&ApiStringFormat::PropertyString( > + &ArraySchema::new("Contact list.", &EMAIL_SCHEMA).schema(), > + )) > + .schema(); I think this new schema could also be used in the update_account API endpoint. I'd add a separate patch after this one for this. > + > +#[api( > + properties: { > + name: { > + type: AcmeAccountName, > + optional: true, > + }, > + contact: { > + schema: ACME_CONTACT_LIST_SCHEMA > + }, > + tos_url: { > + type: String, > + description: "URL of CA TermsOfService - setting this indica= tes agreement.", For most 'simple' parameters (ones that do not have a schema or nested types such as arrays) can have their description provided via a doc comment (see below). This has the benefit that you get that string in the API viewer *and* the Rust docs. In general, we try to have doc comments for all `pub` fields/functions. > + optional: true, > + }, > + directory: { > + type: String, > + description: "The ACME Directory.", > + optional: true, > + }, > + eab_kid: { > + type: String, > + description: "Key Identifier for External Account Binding.", > + optional: true, > + }, > + eab_hmac_key: { > + type: String, > + description: "HMAC Key for External Account Binding.", > + optional: true, > + } > + }, > +)] > +#[derive(Serialize, Deserialize)] > +/// ACME account registration properties. > +pub struct AcmeRegistrationParams { > + #[serde(skip_serializing_if =3D "Option::is_none")] > + pub name: Option, > + > + pub contact: String, > + > + #[serde(skip_serializing_if =3D "Option::is_none")] e.g. like this /// URL of CA TermsOfService - setting this indicates agreement. > + pub tos_url: Option, > + > + #[serde(skip_serializing_if =3D "Option::is_none")] > + pub directory: Option, > + > + #[serde(skip_serializing_if =3D "Option::is_none")] > + pub eab_kid: Option, > + > + #[serde(skip_serializing_if =3D "Option::is_none")] > + pub eab_hmac_key: Option, > +} > diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs > index 5daaa3f..b69e99f 100644 > --- a/lib/pdm-api-types/src/lib.rs > +++ b/lib/pdm-api-types/src/lib.rs > @@ -116,6 +116,8 @@ pub mod sdn; > =20 > pub mod views; > =20 > +pub mod acme; > + > const_regex! { > // just a rough check - dummy acceptor is used before persisting > pub OPENSSL_CIPHERS_REGEX =3D r"^[0-9A-Za-z_:, +!\-@=3D.]+$"; > diff --git a/server/src/api/config/acme.rs b/server/src/api/config/acme.r= s > index 0c583c4..3c40a27 100644 > --- a/server/src/api/config/acme.rs > +++ b/server/src/api/config/acme.rs > @@ -1,5 +1,6 @@ > use anyhow::Error; > =20 > +use pdm_api_types::acme::AcmeRegistrationParams; > use proxmox_router::list_subdirs_api_method; > use proxmox_router::{Router, RpcEnvironment, SubdirMap}; > =20 > @@ -79,31 +80,9 @@ pub fn list_accounts() -> Result, Er= ror> { > #[api( > input: { > properties: { > - name: { > - type: AcmeAccountName, > - optional: true, > - }, > - contact: { > - description: "List of email addresses.", > - }, > - tos_url: { > - description: "URL of CA TermsOfService - setting this in= dicates agreement.", > - optional: true, > - }, > - directory: { > - type: String, > - description: "The ACME Directory.", > - optional: true, > - }, > - eab_kid: { > - type: String, > - description: "Key Identifier for External Account Bindin= g.", > - optional: true, > - }, > - eab_hmac_key: { > - type: String, > - description: "HMAC Key for External Account Binding.", > - optional: true, > + params: { > + type: AcmeRegistrationParams, > + flatten: true > } > }, > }, > @@ -116,16 +95,19 @@ pub fn list_accounts() -> Result, = Error> { > }, > )] > /// Register an ACME account. > -fn register_account( > - name: Option, > - // Todo: email & email-list schema > - contact: String, > - tos_url: Option, > - directory: Option, > - eab_kid: Option, > - eab_hmac_key: Option, > +pub fn register_account( > + params: AcmeRegistrationParams, > rpcenv: &mut dyn RpcEnvironment, > ) -> Result { > + let AcmeRegistrationParams { > + name, > + contact, > + tos_url, > + directory, > + eab_kid, > + eab_hmac_key, > + } =3D params; > + > let auth_id =3D rpcenv.get_auth_id().unwrap(); > let name =3D name.unwrap_or_else(|| unsafe { > AcmeAccountName::from_string_unchecked("default".to_string())