Can you you implement row level security rules (i....
# help
o
Can you you implement row level security rules (i.e. checking
user_id
matches) without using Supabase's login system?
n
Hello @ottohatt! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! 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.
o
hey. I'm trying to issue my own JWTs for limiting the access of clients, but without using the supabase account system
from reading this it looks like you can issue your own JWTs, but how do you go about accessing the information you pass? https://supabase.com/docs/learn/auth-deep-dive/auth-deep-dive-jwts
like if I signed a token with
{custom_user_id: xxxx}
, can I do
auth.custom_user_id()
?
g
I was just about to post that link... Hold on and I'll get you the link to get the jwt info.
n
ottohatt (2022-06-03)
g
https://postgrest.org/en/stable/api.html#http-context jwt.claims contains the jwt info. The Supabase functions just use that.
o
ohhh, so is
auth.email()
a shorthand for
SELECT current_setting('request.jwt', true)::json->>'email'
?
g
There is some null checking but basically
o
very cool, thank you!
n
Thread was archived by @ottohatt. Anyone can send a message to unarchive it.
g
https://github.com/supabase/gotrue/blob/master/migrations/20220224000811_update_auth_functions.up.sql This has the current functions, but note it has to support the 'old' way PostgREST worked as well, which you don't need to do if on recent versions of Supabase.