Re: Add "host" to startup packet

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Lev Kokotov <lev(at)hyperparam(dot)ai>
Subject: Re: Add "host" to startup packet
Date: 2023-04-02 15:28:54
Message-ID: 931641680449201@fszgwlsuez7jpill.myt.yp-c.yandex.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Lev,<br /><br />02.04.2023, 14:43, "Lev Kokotov" &lt;lev(at)hyperparam(dot)ai&gt;:<br /><blockquote><div dir="ltr"><div><div class="b337b69227c3e81c670b9fee40a46dcgmail_signature" dir="ltr"><div>Patch attached below. TLDR, I'd like to add "host" to the startup packet.<br /></div><div><br /></div><div>I'm trying to run multiple Postgres servers in a multi-tenant environment behind a <a href="https://github.com/postgresml/pgcat">pooler</a>. Currently, the only way to differentiate Postgres databases is with the user/dbname combination which are very often included in the startup packet by the client. However, that's not sufficient if you have users that all want to have the user "admin" and the database "production" :)<br /></div><div><br /></div><div>HTTP hosting providers solved this using the "Host" header, allowing the server to identify which website the client wants. In the case of Postgres, this is the DNS or IP address, depending on the client configuration.</div><div><br /></div><div>Upon receiving a startup packet with user, dbname, and host, the pooler (acting also as a proxy) can validate that the credentials exist for the host and that they are valid, and authorize or decline the connection.</div></div></div></div></blockquote><div>I like the idea of giving proxy information on database tenant to which client wants to connect. However, name “host” in web is chosen as part of URL specification. I’m not sure it applies here.</div><div>And it is not clear from your description how server should interpret this information.</div><div><br /></div><br /><blockquote><div dir="ltr"><div class="b337b69227c3e81c670b9fee40a46dcgmail_signature" dir="ltr"><div></div><div>I have never submitted a patch for Postgres before, so I'm not entirely sure how to test this change, although it seems pretty harmless. Any feedback and help are appreciated!</div></div></div></blockquote><br /><div>Well, at minimum from the patch should be clear what purpose new feature has, some documentation and test must be included. You can judge from recently committed libpq load balancing what it takes to add a connection option [0]. But, obviously, it makes sense to discuss it before going all the way of implementation.</div><div><br /></div><div><br /></div><div>Best regards, Andrey Borodin.</div><div><br /></div><div>[0] <a href="https://github.com/postgres/postgres/commit/7f5b19817eaf38e70ad1153db4e644ee9456853e" style="font-family:'-apple-system-body'">https://github.com/postgres/postgres/commit/7f5b1981</a></div>

Attachment Content-Type Size
unknown_filename text/html 2.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-04-02 15:38:25 Re: Add "host" to startup packet
Previous Message Phil Florent 2023-04-02 09:55:47 Support logical replication of DDLs