From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 19B881FF137 for ; Tue, 03 Feb 2026 18:44:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 08657184D; Tue, 3 Feb 2026 18:44:43 +0100 (CET) From: Shan Shaji To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 2/4] api: acme: define API type for ACME registration parameters Date: Tue, 3 Feb 2026 18:44:18 +0100 Message-ID: <20260203174420.453118-3-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260203174420.453118-1-s.shaji@proxmox.com> References: <20260203174420.453118-1-s.shaji@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1770140600474 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.109 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: BPLNMA4FAFF4QXAUQSCZN47PHN3HQSQN X-Message-ID-Hash: BPLNMA4FAFF4QXAUQSCZN47PHN3HQSQN X-MailFrom: s.shaji@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: 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.rs 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, StringSchema}; + +use crate::EMAIL_SCHEMA; + +pub const ACME_CONTACT_LIST_SCHEMA: Schema = + StringSchema::new("List of email addresses, comma seperated.") + .format(&ApiStringFormat::PropertyString( + &ArraySchema::new("Contact list.", &EMAIL_SCHEMA).schema(), + )) + .schema(); + +#[api( + properties: { + name: { + type: AcmeAccountName, + optional: true, + }, + contact: { + schema: ACME_CONTACT_LIST_SCHEMA + }, + tos_url: { + type: String, + description: "URL of CA TermsOfService - setting this indicates agreement.", + 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 = "Option::is_none")] + pub name: Option, + + pub contact: String, + + #[serde(skip_serializing_if = "Option::is_none")] + pub tos_url: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub directory: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + pub eab_kid: Option, + + #[serde(skip_serializing_if = "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; pub mod views; +pub mod acme; + const_regex! { // just a rough check - dummy acceptor is used before persisting pub OPENSSL_CIPHERS_REGEX = r"^[0-9A-Za-z_:, +!\-@=.]+$"; diff --git a/server/src/api/config/acme.rs b/server/src/api/config/acme.rs 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; +use pdm_api_types::acme::AcmeRegistrationParams; use proxmox_router::list_subdirs_api_method; use proxmox_router::{Router, RpcEnvironment, SubdirMap}; @@ -79,31 +80,9 @@ pub fn list_accounts() -> Result, Error> { #[api( input: { properties: { - name: { - type: AcmeAccountName, - optional: true, - }, - contact: { - description: "List of email addresses.", - }, - tos_url: { - description: "URL of CA TermsOfService - setting this indicates agreement.", - 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, + 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, + } = params; + let auth_id = rpcenv.get_auth_id().unwrap(); let name = name.unwrap_or_else(|| unsafe { AcmeAccountName::from_string_unchecked("default".to_string()) -- 2.47.3