How does postgres get the current authenticated us...
# help
a
How does postgres get the current authenticated user, i.e.
auth
to run checks in RLS policies?
n
Hello @Avin! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
p
It looks like the jwt of the client is passed to postgres who can decode it (https://supabase.com/docs/learn/auth-deep-dive/auth-row-level-security last code block) but i can't figure out how
n
Avin (2022-03-22)
g
Here is an example of the uid function: create or replace function auth.uid() returns uuid language sql stable as $$ select nullif( coalesce( current_setting('request.jwt.claim.sub', true), (current_setting('request.jwt.claims', true)::jsonb ->> 'sub') ), '' )::uuid $$; And PostgREST provides the jwt info. https://postgrest.org/en/stable/api.html#http-context