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 58F9471BF8 for ; Wed, 30 Jun 2021 09:28:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 46AFD16B8C for ; Wed, 30 Jun 2021 09:28: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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 73E9D16B81 for ; Wed, 30 Jun 2021 09:28:23 +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 42BE54308E for ; Wed, 30 Jun 2021 09:28:23 +0200 (CEST) Date: Wed, 30 Jun 2021 09:28:15 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20210630061007.3345396-1-dietmar@proxmox.com> <20210630061007.3345396-2-dietmar@proxmox.com> In-Reply-To: <20210630061007.3345396-2-dietmar@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1625037501.bqm0b1j9mz.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.579 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. [proxmox.com, accesscontrol.pm] URI_PHISH 0.001 Phishing using web form Subject: Re: [pve-devel] [PATCH pve-access-control v2 1/5] check_user_enabled: also check if user is expired 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, 30 Jun 2021 07:28:54 -0000 the check is cheap, so it does not matter much that it happens in more=20 places now (like for every request with a ticket in addition to the old=20 every request with a token). would have been nice to mention whether this is intentional though ;) On June 30, 2021 8:10 am, Dietmar Maurer wrote: > --- > src/PVE/AccessControl.pm | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 deletions(-) >=20 > diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm > index 2569a35..8628678 100644 > --- a/src/PVE/AccessControl.pm > +++ b/src/PVE/AccessControl.pm > @@ -428,12 +428,10 @@ sub verify_token { > check_user_enabled($usercfg, $username); > check_token_exist($usercfg, $username, $token); > =20 > - my $ctime =3D time(); > - > my $user =3D $usercfg->{users}->{$username}; > - die "account expired\n" if $user->{expire} && ($user->{expire} < $ct= ime); > - > my $token_info =3D $user->{tokens}->{$token}; > + > + my $ctime =3D time(); > die "token expired\n" if $token_info->{expire} && ($token_info->{exp= ire} < $ctime); > =20 > die "invalid token value!\n" if !PVE::Cluster::verify_token($tokenid= , $value); > @@ -579,6 +577,11 @@ sub check_user_enabled { > =20 > die "user '$username' is disabled\n" if !$noerr; > =20 > + my $ctime =3D time(); > + my $expire =3D $usercfg->{users}->{$username}->{expire}; > + > + die "account expired\n" if $expire && ($expire < $ctime); > + > return undef; > } > =20 > @@ -629,11 +632,6 @@ sub authenticate_user { > =20 > check_user_enabled($usercfg, $username); > =20 > - my $ctime =3D time(); > - my $expire =3D $usercfg->{users}->{$username}->{expire}; > - > - die "account expired\n" if $expire && ($expire < $ctime); > - > my $domain_cfg =3D cfs_read_file('domains.cfg'); > =20 > my $cfg =3D $domain_cfg->{ids}->{$realm}; > --=20 > 2.30.2 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20