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 1FEF272425 for ; Thu, 1 Jul 2021 14:42:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1764924C8D for ; Thu, 1 Jul 2021 14:42:24 +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 id 3B2D024C5C for ; Thu, 1 Jul 2021 14:42:22 +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 097E440304 for ; Thu, 1 Jul 2021 14:42:22 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Thu, 1 Jul 2021 14:25:00 +0200 Message-Id: <20210701122506.503289-2-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210701122506.503289-1-d.csapak@proxmox.com> References: <20210701122506.503289-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.696 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 Subject: [pve-devel] [PATCH access-control 1/1] api: user: add realmtype to user list X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2021 12:42:24 -0000 this makes it much easier to determine if a user can e.g. change a password or tfa, based on realm Signed-off-by: Dominik Csapak --- src/PVE/API2/User.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/User.pm b/src/PVE/API2/User.pm index 05de57f..f1249a8 100644 --- a/src/PVE/API2/User.pm +++ b/src/PVE/API2/User.pm @@ -149,7 +149,11 @@ __PACKAGE__->register_method ({ items => $token_info_extend->({ tokenid => get_standard_option('token-subid'), }), - } + }, + realmtype => { + type => 'string', + description => 'The type of the users realm', + }, }, }, links => [ { rel => 'child', href => "{userid}" } ], @@ -161,6 +165,9 @@ __PACKAGE__->register_method ({ my $usercfg = $rpcenv->{user_cfg}; my $authuser = $rpcenv->get_user(); + my $domainscfg = cfs_read_file('domains.cfg'); + my $domainids = $domainscfg->{ids}; + my $res = []; my $privs = [ 'User.Modify', 'Sys.Audit' ]; @@ -184,6 +191,12 @@ __PACKAGE__->register_method ({ $entry->{tokens} = [ map { { tokenid => $_, %{$entry->{tokens}->{$_}} } } sort keys %{$entry->{tokens}} ] if defined($entry->{tokens}); + my (undef, undef, $realm) = PVE::AccessControl::verify_username($user, 1); + + if (defined($realm) && $domainids->{$realm}) { + $entry->{realmtype} = $domainids->{$realm}->{type}; + } + $entry->{userid} = $user; push @$res, $entry; } -- 2.30.2