Re: dblink: Add SCRAM pass-through authentication - Mailing list pgsql-hackers

From Jacob Champion
Subject Re: dblink: Add SCRAM pass-through authentication
Date
Msg-id CAOYmi+=43L0qRd422Y_9QKSZJxJ25X+PT=R-GJBg1ANzgXCLvg@mail.gmail.com
Whole thread Raw
In response to Re: dblink: Add SCRAM pass-through authentication  (Matheus Alcantara <matheusssilv97@gmail.com>)
List pgsql-hackers
On Fri, Feb 21, 2025 at 6:48 AM Matheus Alcantara
<matheusssilv97@gmail.com> wrote:
> Hi, thanks for all the reviews. Attached v3 with some fixes.

Thanks! I keep getting pulled away from my review of 0002, so I'll
just comment on 0001 to get things moving again; sorry for the delay.

> I agree, I've just declared outside of get_connect_string because on 0002 we
> also need the user mapping for UseScramPassthrough function, so I think that it
> would make the review more easier.

Ah, I missed that part of 0002. Works for me.

> > > -       if (rconn)
> > > -           pfree(rconn);
> >
> > Looks like this code in dblink_connect() was dropped.
> >
> Oops, fixed on connect_pg_server since this logic was moved to this function.

I think this fix may break the other usage in dblink_get_conn(), where
rconn comes from a hash entry. Maybe dblink_connect() should instead
put a PG_CATCH/pfree/PG_RE_THROW around the call to
connect_pg_server(), to ensure that the rconn allocation in
TopMemoryContext doesn't get leaked?

> ## Questions:
>
> - The new dblink_connstr_has_scam_require_auth function is very similar with
> dblink_connstr_has_pw, we may create a common function for these or let it
> duplicated?

My preference would be to wait for a third [1], but at the very least
I think the new function should go right next to the old one, to
highlight the similarity.

I have attached some stylistic suggestions, plus pgindent/pgperltidy
tweaks, as fixup commits 0002 and 0004.

Thanks,
--Jacob

[1] https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)

Attachment

pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Flaky 003_start_stop.pl test
Next
From: Greg Sabino Mullane
Date:
Subject: Re: PATCH: warn about, and deprecate, clear text passwords