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 688851FF38F for ; Tue, 4 Jun 2024 14:49:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 2C23C11D11; Tue, 4 Jun 2024 14:50:21 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Tue, 4 Jun 2024 14:50:06 +0200 Message-ID: <20240604125014.210321-4-g.goller@proxmox.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240604125014.210321-1-g.goller@proxmox.com> References: <20240604125014.210321-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.062 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-backup-proxy.rs, node.rs, config.rs] Subject: [pbs-devel] [PATCH proxmox-backup v2 3/5] api: add consent api handler and config option X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Add consent_text option to the node.cfg config. Embed the value into index.html file using handlebars. Signed-off-by: Gabriel Goller --- src/api2/node/config.rs | 8 ++++++++ src/bin/proxmox-backup-proxy.rs | 11 ++++++++--- src/config/node.rs | 4 ++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/api2/node/config.rs b/src/api2/node/config.rs index 86a73cf8..19ede24b 100644 --- a/src/api2/node/config.rs +++ b/src/api2/node/config.rs @@ -67,6 +67,8 @@ pub enum DeletableProperty { Description, /// Delete the task-log-max-days property TaskLogMaxDays, + /// Delete the consent-text property + ConsentText, } #[api( @@ -155,6 +157,9 @@ pub fn update_node_config( DeletableProperty::TaskLogMaxDays => { config.task_log_max_days = None; } + DeletableProperty::ConsentText => { + config.consent_text = None; + } } } } @@ -198,6 +203,9 @@ pub fn update_node_config( if update.task_log_max_days.is_some() { config.task_log_max_days = update.task_log_max_days; } + if update.consent_text.is_some() { + config.consent_text = update.consent_text; + } crate::config::node::save_config(&config)?; diff --git a/src/bin/proxmox-backup-proxy.rs b/src/bin/proxmox-backup-proxy.rs index 15444685..4d8542b6 100644 --- a/src/bin/proxmox-backup-proxy.rs +++ b/src/bin/proxmox-backup-proxy.rs @@ -49,12 +49,12 @@ use pbs_api_types::{ use proxmox_rest_server::daemon; -use proxmox_backup::auth_helpers::*; use proxmox_backup::server; use proxmox_backup::tools::{ disks::{zfs_dataset_stats, DiskManage}, PROXMOX_BACKUP_TCP_KEEPALIVE_TIME, }; +use proxmox_backup::{auth_helpers::*, config}; use proxmox_backup::api2::pull::do_sync_job; use proxmox_backup::api2::tape::backup::do_tape_backup_job; @@ -87,7 +87,7 @@ fn get_language(headers: &http::HeaderMap) -> String { match cookie_from_header(headers, "PBSLangCookie") { Some(cookie_lang) if exists(&cookie_lang) => cookie_lang, - _ => match proxmox_backup::config::node::config().map(|(cfg, _)| cfg.default_lang) { + _ => match config::node::config().map(|(cfg, _)| cfg.default_lang) { Ok(Some(default_lang)) if exists(&default_lang) => default_lang, _ => String::from(""), }, @@ -152,6 +152,10 @@ async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response let theme = get_theme(&parts.headers); + let consent = config::node::config() + .ok() + .and_then(|config| config.0.consent_text) + .unwrap_or("".to_string()); let data = json!({ "NodeName": nodename, "UserName": user, @@ -160,6 +164,7 @@ async fn get_index_future(env: RestEnvironment, parts: Parts) -> Response "theme": theme, "auto": theme == "auto", "debug": debug, + "consentText": consent, }); let (ct, index) = match api.render_template(template_file, &data) { @@ -387,7 +392,7 @@ fn make_tls_acceptor() -> Result { let key_path = configdir!("/proxy.key"); let cert_path = configdir!("/proxy.pem"); - let (config, _) = proxmox_backup::config::node::config()?; + let (config, _) = config::node::config()?; let ciphers_tls_1_3 = config.ciphers_tls_1_3; let ciphers_tls_1_2 = config.ciphers_tls_1_2; diff --git a/src/config/node.rs b/src/config/node.rs index 937beb3a..77f72073 100644 --- a/src/config/node.rs +++ b/src/config/node.rs @@ -225,6 +225,10 @@ pub struct NodeConfig { /// Maximum days to keep Task logs #[serde(skip_serializing_if = "Option::is_none")] pub task_log_max_days: Option, + + /// Consent banner text + #[serde(skip_serializing_if = "Option::is_none")] + pub consent_text: Option, } impl NodeConfig { -- 2.43.0 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel