Re: What hook would you recommend for "one time, post authentication"?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Daniel Farina <daniel(at)heroku(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: What hook would you recommend for "one time, post authentication"?
Date: 2013-10-29 01:27:12
Message-ID: 18144.1383010032@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Daniel Farina <daniel(at)heroku(dot)com> writes:
> What hook would you recommend that matches this criteria:
> * Runs post-authentication

> * ..Once

ClientAuthentication_hook

> My general approach has been to try to use
> GetUserNameFromId(GetSessionUserId()), but this requires
> InitializeSessionUserId be called first, and that has been causing me
> some trouble.

So don't do that. The HBA code uses

roleid = get_role_oid(port->user_name, true);

and actually if you just want the string form you could use
port->user_name without any extra pushups (bearing in mind that
it might or might not be a valid user name).

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2013-10-29 01:28:39 Re: ERROR : 'tuple concurrently updated'
Previous Message Andres Freund 2013-10-29 01:16:23 missing RelationCloseSmgr in FreeFakeRelcacheEntry?