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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BE32F68D98 for ; Fri, 28 Aug 2020 13:20:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A962F20888 for ; Fri, 28 Aug 2020 13:19:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 0C3912087D for ; Fri, 28 Aug 2020 13:19:48 +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 C63C343F0F for ; Fri, 28 Aug 2020 13:19:47 +0200 (CEST) From: Wolfgang Link To: pve-devel@pve.proxmox.com Date: Fri, 28 Aug 2020 13:19:43 +0200 Message-Id: <20200828111943.26450-1-w.link@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an 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.pm, accesscontrol.pm] Subject: [pve-devel] [access-contorl] fix #2947 login name for the LDAP/AD realm can be case-insensitive 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: Fri, 28 Aug 2020 11:20:21 -0000 This is an optional for LDAP and AD realm. The default behavior is case-sensitive. Signed-off-by: Wolfgang Link --- PVE/API2/AccessControl.pm | 20 ++++++++++++++++++++ PVE/Auth/LDAP.pm | 7 +++++++ 2 files changed, 27 insertions(+) diff --git a/PVE/API2/AccessControl.pm b/PVE/API2/AccessControl.pm index fd27786..4b4d0be 100644 --- a/PVE/API2/AccessControl.pm +++ b/PVE/API2/AccessControl.pm @@ -226,6 +226,25 @@ __PACKAGE__->register_method ({ returns => { type => "null" }, code => sub { return undef; }}); +sub lookup_username { + my ($username) = @_; + + $username =~ /@(.+)/; + + my $realm = $1; + my $domain_cfg = cfs_read_file("domains.cfg"); + my $casesensitive = $domain_cfg->{ids}->{$realm}->{casesensitive} // 1; + my $usercfg = cfs_read_file('user.cfg'); + + if ($casesensitive == 0) { + foreach my $user_name (keys %{$usercfg->{users}}) { + return $user_name if lc $username eq lc $user_name; + } + } + + return $username; +}; + __PACKAGE__->register_method ({ name => 'create_ticket', path => 'ticket', @@ -292,6 +311,7 @@ __PACKAGE__->register_method ({ my $username = $param->{username}; $username .= "\@$param->{realm}" if $param->{realm}; + $username = lookup_username($username); my $rpcenv = PVE::RPCEnvironment::get(); my $res; diff --git a/PVE/Auth/LDAP.pm b/PVE/Auth/LDAP.pm index 09b2202..75cce0f 100755 --- a/PVE/Auth/LDAP.pm +++ b/PVE/Auth/LDAP.pm @@ -129,6 +129,12 @@ sub properties { optional => 1, default => 'ldap', }, + casesensitive => { + description => "username is case-sensitive", + type => 'boolean', + optional => 1, + default => 1, + } }; } @@ -159,6 +165,7 @@ sub options { group_classes => { optional => 1 }, 'sync-defaults-options' => { optional => 1 }, mode => { optional => 1 }, + casesensitive => { optional => 1 }, }; } -- 2.20.1