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 63AFE7E478 for ; Wed, 10 Nov 2021 13:49:36 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 554D71BFD3 for ; Wed, 10 Nov 2021 13:49:06 +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 id 398A41BF94 for ; Wed, 10 Nov 2021 13:49:05 +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 1089744BB8 for ; Wed, 10 Nov 2021 13:49:05 +0100 (CET) From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Date: Wed, 10 Nov 2021 13:49:01 +0100 Message-Id: <20211110124904.164053-3-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211110124904.164053-1-w.bumiller@proxmox.com> References: <20211110124904.164053-1-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.485 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. [accesscontrol.pm] Subject: [pve-devel] [PATCH access-control 2/4] check enforced realm tfa type in new auth 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: Wed, 10 Nov 2021 12:49:36 -0000 this way we could also add webauthn as a required tfa type to the realm configs later on Signed-off-by: Wolfgang Bumiller --- src/PVE/AccessControl.pm | 48 +++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm index 49cef94..c043404 100644 --- a/src/PVE/AccessControl.pm +++ b/src/PVE/AccessControl.pm @@ -749,29 +749,41 @@ sub authenticate_2nd_new : prototype($$$$) { } my $realm_type = $realm_tfa && $realm_tfa->{type}; - if (defined($realm_type) && $realm_type eq 'yubico') { - # Yubico auth will not be supported in rust for now... - if (!defined($tfa_challenge)) { - my $challenge = { yubico => JSON::true }; - # Even with yubico auth we do allow recovery keys to be used: - if (my $recovery = $tfa_cfg->recovery_state($username)) { - $challenge->{recovery} = $recovery; + $realm_type = 'totp' if $realm_type eq 'oath'; # we used to call it that + # verify realm type unless using recovery keys: + if (defined($realm_type)) { + if ($realm_type eq 'yubico') { + # Yubico auth will not be supported in rust for now... + if (!defined($tfa_challenge)) { + my $challenge = { yubico => JSON::true }; + # Even with yubico auth we do allow recovery keys to be used: + if (my $recovery = $tfa_cfg->recovery_state($username)) { + $challenge->{recovery} = $recovery; + } + return to_json($challenge); } - return to_json($challenge); - } - if ($otp =~ /^yubico:(.*)$/) { - $otp = $1; - # Defer to after unlocking the TFA config: - return sub { - authenticate_yubico_new($tfa_cfg, $username, $realm_tfa, $tfa_challenge, $otp); - }; + if ($otp =~ /^yubico:(.*)$/) { + $otp = $1; + # Defer to after unlocking the TFA config: + return sub { + authenticate_yubico_new( + $tfa_cfg, $username, $realm_tfa, $tfa_challenge, $otp, + ); + }; + } } - # Beside the realm configured auth we only allow recovery keys: - if ($otp !~ /^recovery:/) { - die "realm requires yubico authentication\n"; + my $response_type; + if (defined($otp)) { + if ($otp !~ /^([^:]+):/) { + die "bad otp response\n"; + } + $response_type = $1; } + + die "realm requires $realm_type authentication\n" + if $response_type && $response_type ne 'recovery' && $response_type ne $realm_type; } configure_u2f_and_wa($tfa_cfg); -- 2.30.2