From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 44381921E5 for ; Fri, 10 Feb 2023 11:16:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 25B742DC9A for ; Fri, 10 Feb 2023 11:16:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 10 Feb 2023 11:16:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2FABF46754 for ; Fri, 10 Feb 2023 11:16:27 +0100 (CET) Date: Fri, 10 Feb 2023 11:16:20 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20230209133128.695211-1-l.wagner@proxmox.com> <20230209133128.695211-11-l.wagner@proxmox.com> In-Reply-To: <20230209133128.695211-11-l.wagner@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1676023936.ktlvuvehan.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.127 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [ldap.rs, mod.rs, proxmox-backup-manager.rs, domains.rs] Subject: Re: [pbs-devel] [PATCH v3 proxmox-backup 10/18] manager: add commands for managing LDAP realms 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: , X-List-Received-Date: Fri, 10 Feb 2023 10:16:28 -0000 On February 9, 2023 2:31 pm, Lukas Wagner wrote: > Adds commands for managing LDAP realms, including user sync, to > `proxmox-backup-manager`. >=20 > Signed-off-by: Lukas Wagner > --- > pbs-config/src/domains.rs | 12 +- > src/bin/proxmox-backup-manager.rs | 1 + > src/bin/proxmox_backup_manager/ldap.rs | 152 +++++++++++++++++++++++++ > src/bin/proxmox_backup_manager/mod.rs | 2 + > 4 files changed, 165 insertions(+), 2 deletions(-) > create mode 100644 src/bin/proxmox_backup_manager/ldap.rs >=20 > [..] > diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-m= anager.rs > index 86adabe3..740fdc49 100644 > --- a/src/bin/proxmox-backup-manager.rs > +++ b/src/bin/proxmox-backup-manager.rs > @@ -427,6 +427,7 @@ async fn run() -> Result<(), Error> { > .insert("datastore", datastore_commands()) > .insert("disk", disk_commands()) > .insert("dns", dns_commands()) > + .insert("ldap", ldap_commands()) > .insert("network", network_commands()) > .insert("node", node_commands()) > .insert("user", user_commands()) > diff --git a/src/bin/proxmox_backup_manager/ldap.rs b/src/bin/proxmox_bac= kup_manager/ldap.rs > new file mode 100644 > index 00000000..538c313b > --- /dev/null > +++ b/src/bin/proxmox_backup_manager/ldap.rs > @@ -0,0 +1,152 @@ > +use anyhow::Error; > +use serde_json::Value; > + > +use proxmox_router::{cli::*, ApiHandler, Permission, RpcEnvironment}; > +use proxmox_schema::api; > + > +use pbs_api_types::{ > + Realm, PRIV_PERMISSIONS_MODIFY, PROXMOX_UPID_REGEX, REALM_ID_SCHEMA,= REMOVE_VANISHED_SCHEMA, > +}; > + > +use proxmox_backup::api2; > + > [..] > + > +#[api( > + protected: true, > + input: { > + properties: { > + realm: { > + type: Realm, > + }, > + "dry-run": { > + type: bool, > + description: "If set, do not create/delete anything", > + default: false, > + optional: true, > + }, > + "remove-vanished": { > + optional: true, > + schema: REMOVE_VANISHED_SCHEMA, > + }, > + "enable-new": { > + description: "Enable newly synced users immediately", > + optional: true, > + type: bool, > + } > + }, > + }, > + access: { > + permission: &Permission::Privilege(&["access", "users"], PRIV_PE= RMISSIONS_MODIFY, false), > + }, > +)] > +/// Sync a given LDAP realm > +async fn sync_ldap_realm(param: Value, rpcenv: &mut dyn RpcEnvironment) = -> Result { > + let info =3D &api2::access::domain::API_METHOD_SYNC_REALM; > + let data =3D match info.handler { > + ApiHandler::Sync(handler) =3D> (handler)(param, info, rpcenv)?, > + _ =3D> unreachable!(), > + }; > + > + if let Some(upid) =3D data.as_str() { > + if PROXMOX_UPID_REGEX.is_match(upid) { > + proxmox_rest_server::handle_worker(upid).await?; > + } > + } possibly late to the party given that the "handle_worker" move got applied = already.. is there a good reason for introducing this instead of calling the endpoint= over the API and using the "I just spawned a task and want to poll the output" h= elper (pbs_client::view_task_result), like the rest of proxmox-backup-manager doe= s? > + > + Ok(Value::Null) > +} > +