Postgres's official docs indicate that functions defined with SECURITY DEFINER run with privileges of the user who created it.
However other sources, such as here and here, claim it is the privileges of the owner of the function.
Which is correct?
(for 9.4+)
security definer
: give unprivileged users access to privileged things) – Naturopathysecurity definer
lets users "borrow" some elevated privileges only while executing the function. Let's say I have a function that INSERTs data, that I want a restricted user to be able to execute. I would prefer the user to temporarily emulate a function "owner" who can only SELECT and INSERT, rather than a superuser who can create functions and also DELETE, TRUNCATE, UPDATE, etc. – Septi