From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.gruenbichler@proxmox.com>
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 3171970782
 for <pve-devel@lists.proxmox.com>; Mon,  6 Sep 2021 10:52:37 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 242C9E479
 for <pve-devel@lists.proxmox.com>; Mon,  6 Sep 2021 10:52:37 +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 90417E46E
 for <pve-devel@lists.proxmox.com>; Mon,  6 Sep 2021 10:52:36 +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 617A444594
 for <pve-devel@lists.proxmox.com>; Mon,  6 Sep 2021 10:52:36 +0200 (CEST)
Date: Mon, 06 Sep 2021 10:52:29 +0200
From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Thomas Lamprecht <t.lamprecht@proxmox.com>
References: <20210713080917.1546780-1-f.gruenbichler@proxmox.com>
 <d35d4eec-1c08-cd14-0fde-d2a42a8288d0@proxmox.com>
In-Reply-To: <d35d4eec-1c08-cd14-0fde-d2a42a8288d0@proxmox.com>
MIME-Version: 1.0
User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid)
Message-Id: <1630917949.olp1i1j6ub.astroid@nora.none>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.424 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: Re: [pve-devel] [PATCH access-control] fix #3513: pass configured
 proxy to OpenID
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 06 Sep 2021 08:52:37 -0000

On August 25, 2021 6:31 pm, Thomas Lamprecht wrote:
> On 13/07/2021 10:09, Fabian Gr=C3=BCnbichler wrote:
>> Signed-off-by: Fabian Gr=C3=BCnbichler <f.gruenbichler@proxmox.com>
>> ---
>> seemed like the easiest way to fix this - but we could also change the
>> proxmox-openid-rs API to take the proxy as parameter..
>>=20
>=20
> seems OK in general, but do we only want to set it in case it actually ha=
s
> a value? Not sure if non-existing and existing but empty makes any differ=
ence
> here - e.g., a behavior that one could possibly imagine is that it would =
override
> another source/default for a proxy to force no-proxy...
>=20
> Mostly just asking if you thought about that, it's probably just a very v=
ague and
> theoretical issue..

Yeah I think this would be rather theoretical, as our API services run=20
without that env variable set by default, so a user would have to=20
edit/override the systemd unit to set the env variable instead of using=20
our built-in mechanism..

but alas,

local %ENV;
if (my $http_proxy =3D $dcconf->{http_proxy}) {
  $ENV{all_proxy} =3D $http_proxy;
}

should work just as well but still preserve a fallback to pre-existing=20
env variable

>=20
>>  src/PVE/API2/OpenId.pm | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>=20
>> diff --git a/src/PVE/API2/OpenId.pm b/src/PVE/API2/OpenId.pm
>> index 22423ba..9080865 100644
>> --- a/src/PVE/API2/OpenId.pm
>> +++ b/src/PVE/API2/OpenId.pm
>> @@ -97,6 +97,9 @@ __PACKAGE__->register_method ({
>>      code =3D> sub {
>>  	my ($param) =3D @_;
>> =20
>> +	my $dcconf =3D PVE::Cluster::cfs_read_file('datacenter.cfg');
>> +	local $ENV{all_proxy} =3D $dcconf->{http_proxy};
>> +
>>  	my $realm =3D extract_param($param, 'realm');
>>  	my $redirect_url =3D extract_param($param, 'redirect-url');
>> =20
>> @@ -149,6 +152,9 @@ __PACKAGE__->register_method ({
>> =20
>>  	my $res;
>>  	eval {
>> +	    my $dcconf =3D PVE::Cluster::cfs_read_file('datacenter.cfg');
>> +	    local $ENV{all_proxy} =3D $dcconf->{http_proxy};
>> +
>>  	    my ($realm, $private_auth_state) =3D PVE::RS::OpenId::verify_publi=
c_auth_state(
>>  		$openid_state_path, $param->{'state'});
>> =20
>>=20
>=20
>=20