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 950AE8D7B for ; Fri, 23 Jun 2023 08:04:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7C7012E7F6 for ; Fri, 23 Jun 2023 08:04:13 +0200 (CEST) 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, 23 Jun 2023 08:04:13 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BEB8242CF4 for ; Fri, 23 Jun 2023 08:04:12 +0200 (CEST) Date: Fri, 23 Jun 2023 08:04:08 +0200 From: Wolfgang Bumiller To: Maximiliano Sandoval Cc: pbs-devel@lists.proxmox.com Message-ID: References: <20230620133908.250387-1-m.sandoval@proxmox.com> <20230620133908.250387-3-m.sandoval@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230620133908.250387-3-m.sandoval@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.124 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 - Subject: Re: [pbs-devel] [PATCH v2 manager 2/2] fix #4734: manager: add user tfa {list, delete} commands 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, 23 Jun 2023 06:04:13 -0000 1 minor thing I missed in the 1st round On Tue, Jun 20, 2023 at 03:39:08PM +0200, Maximiliano Sandoval wrote: (...) > diff --git a/src/config/tfa.rs b/src/config/tfa.rs > index 6b1312bb..3cd7f9aa 100644 > --- a/src/config/tfa.rs > +++ b/src/config/tfa.rs > @@ -1,3 +1,4 @@ > +use std::collections::HashMap; > use std::fs::File; > use std::io::{self, Read, Seek, SeekFrom}; > use std::os::unix::fs::OpenOptionsExt; > @@ -302,3 +303,50 @@ impl proxmox_tfa::api::UserChallengeAccess for TfaUserChallengeData { > TfaUserChallengeData::save(self) > } > } > + > +// shell completion helper > +pub fn complete_tfa_id(_arg: &str, param: &HashMap) -> Vec { > + let mut results = Vec::new(); > + > + let data = match read() { > + Ok(data) => data, > + Err(_err) => return results, > + }; > + let user = match param > + .get("userid") > + .and_then(|user_name| data.users.get(user_name)) > + { > + Some(user) => user, > + None => return results, > + }; > + > + results.extend( > + user.totp > + .iter() > + .map(|token| token.info.id.clone()) > + .collect::>(), ^ .extend() takes an `IntoIterator`, you already have an iterator, you can drop the `.collect()` call here > + ); > + results.extend( > + user.u2f > + .iter() > + .map(|token| token.info.id.clone()) > + .collect::>(), ^ and here > + ); > + results.extend( > + user.webauthn > + .iter() > + .map(|token| token.info.id.clone()) > + .collect::>(), ^ and here > + ); > + results.extend( > + user.yubico > + .iter() > + .map(|token| token.info.id.clone()) > + .collect::>(), ^ and here > + ); > + if user.recovery.is_some() { > + results.push("recovery".to_string()); > + }; > + > + results > +} > -- > 2.39.2