-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
This is follow up of #2309 (comment)
This could be used to set session user or set session extra credential.
We'd want this to use standard syntax like SET SESSION AUTHORIZATION. The SQL standard doesn't seem to define the access model and leaves it up to the implementation:
If V is not equal to the current value of the SQL-session user identifier of the current SQL-session context, then the restrictions on the permissible values for V are implementation-defined.
It's more complicated because there are two different models, similar to setuid vs seteuid in UNIX. The PostgreSQL implementation is like seteuid -- the access check is based on the originally authenticated user. Thus, it is possible to temporarily become an unprivileged user, then switch back.
The model you want is like setuid -- the access check is based on the current user. Thus, switching users permanently revokes all of privileges of the current user. For example, user A could switch to user B, but then would not be allowed to switch back to A.
PostgreSql docs: https://www.postgresql.org/docs/current/sql-set-session-authorization.html