current_user inside SECURITY DEFINER function? - Mailing list pgsql-general

From Richard Hayward
Subject current_user inside SECURITY DEFINER function?
Date
Msg-id ctllc1lqcht4a2bcn4j1vo35r0oqe28vul@4ax.com
Whole thread Raw
Responses Re: current_user inside SECURITY DEFINER function?
Re: current_user inside SECURITY DEFINER function?
Re: current_user inside SECURITY DEFINER function?
List pgsql-general
Is there any way to get the name of the current user inside a PL/pgSQL
function that is defined with security definer?

current_user gives the name of the user who created the function.

The reason I want this is that I intend to use functions to maintain
security, like this:

userA has only select permission on myTable.

The only way userA can insert to myTable is by providing parameters
for and executing myFunction.

myFunction was created by user postgres who does have insert
permission on myTable. However the code inside myFunction needs to do
different things, depending on who called it.

Is there any way of getting the user?

regards
Richard


pgsql-general by date:

Previous
From: Clark Allan
Date:
Subject: Re: PostgreSQL sequence within function
Next
From: Clark Allan
Date:
Subject: Re: PostgreSQL sequence within function