Re: What hook would you recommend for "one time, post authentication"? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: What hook would you recommend for "one time, post authentication"?
Date
Msg-id 18144.1383010032@sss.pgh.pa.us
Whole thread Raw
In response to What hook would you recommend for "one time, post authentication"?  (Daniel Farina <daniel@heroku.com>)
Responses Re: What hook would you recommend for "one time, post authentication"?  (Daniel Farina <daniel@heroku.com>)
List pgsql-hackers
Daniel Farina <daniel@heroku.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



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: missing RelationCloseSmgr in FreeFakeRelcacheEntry?
Next
From: Craig Ringer
Date:
Subject: Re: ERROR : 'tuple concurrently updated'