public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Hannes Laimer <h.laimer@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v2 3/5] fix #4382: api: remove permissions and tokens of user on deletion
Date: Fri, 4 Apr 2025 17:14:43 +0200	[thread overview]
Message-ID: <6d359560-89a4-4335-9604-1a6cb04d7ce5@proxmox.com> (raw)
In-Reply-To: <20250404151017.32991-4-h.laimer@proxmox.com>

On 4/4/25 17:10, Hannes Laimer wrote:
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
>   src/api2/access/user.rs | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
> 
> diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs
> index bba5bb2c0..a51ee8f3f 100644
> --- a/src/api2/access/user.rs
> +++ b/src/api2/access/user.rs
> @@ -353,6 +353,7 @@ pub async fn update_user(
>   pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error> {
>       let _lock = pbs_config::user::lock_config()?;
>       let _tfa_lock = crate::config::tfa::write_lock()?;
> +    let _acl_lock = pbs_config::acl::lock_config()?;
>   
>       let (mut config, expected_digest) = pbs_config::user::config()?;
>   
> @@ -380,6 +381,19 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
>           eprintln!("error updating TFA config after deleting user {userid:?} {err}",);
>       }
>   
> +    let user_tokens: Vec<ApiToken> = config
> +        .convert_to_typed_array::<ApiToken>("token")?
> +        .into_iter()
> +        .filter(|token| token.tokenid.user().eq(&userid))
> +        .collect();
> +
> +    let (mut acl_tree, _digest) = pbs_config::acl::config()?;
> +    for token in user_tokens {
> +        if let Some(name) = token.tokenid.tokenname() {
> +            do_delete_token(name.to_owned(), &userid, &mut config, &mut acl_tree)?;
> +        }
> +    }

Unfortunately you were faster with the rebase an probably missed my 
previous comment. Referencing it for this series, so it does get 
considered: 
https://lore.proxmox.com/pbs-devel/20fe5ca6-889d-4930-ae18-457bc3abf5a5@proxmox.com/

>       Ok(())
>   }
>   



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2025-04-04 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-04 15:10 [pbs-devel] [PATCH proxmox-backup v2 0/5] ACL removal on user/token deletion + token regeneration Hannes Laimer
2025-04-04 15:10 ` [pbs-devel] [PATCH proxmox-backup v2 1/5] pbs-config: move secret generation into token_shadow Hannes Laimer
2025-04-04 15:10 ` [pbs-devel] [PATCH proxmox-backup v2 2/5] fix #4382: api: access: remove permissions of token on deletion Hannes Laimer
2025-04-04 15:10 ` [pbs-devel] [PATCH proxmox-backup v2 3/5] fix #4382: api: remove permissions and tokens of user " Hannes Laimer
2025-04-04 15:14   ` Christian Ebner [this message]
2025-04-04 15:10 ` [pbs-devel] [PATCH proxmox-backup v2 4/5] fix #3887: api: access: allow secret regeneration Hannes Laimer
2025-04-04 15:10 ` [pbs-devel] [PATCH proxmox-backup v2 5/5] fix #3887: ui: add regenerate token button Hannes Laimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6d359560-89a4-4335-9604-1a6cb04d7ce5@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=h.laimer@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal