© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
20 replies
javagoogles

Access user_metadata property from JWT in RLS

Hi, I've been reading up on the docs and even using ChatGPT to try and find out how to get RLS working for my tables.

I have table
data
data
that relies on a table
current_members
current_members
for whether or not they can access whatever is in
data
data
. The problem is,
current_members
current_members
has a
user_id
user_id
column that is from the user's discord id, not the inbuilt id, so I can't go
auth.uid()
auth.uid()
, instead I have to get it from the auth JWT:
(EXISTS ( SELECT 1
   FROM current_members
  WHERE ((current_members.user_id)::text = ((auth.jwt() -> 'user_metadata'::text) ->> 'sub'::text))))
(EXISTS ( SELECT 1
   FROM current_members
  WHERE ((current_members.user_id)::text = ((auth.jwt() -> 'user_metadata'::text) ->> 'sub'::text))))

I'm fairly sure I've got the syntax for the JSONB wrong - would very much appreciate the help.
Row Level Security | Supabase Docs
Using Row Level Security with Supabase Auth.
Row Level Security | Supabase Docs
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Get JWT from another user
SupabaseSSupabase / help-and-questions
8mo ago
user_metadata
SupabaseSSupabase / help-and-questions
4y ago
RLS based on custom jwt
SupabaseSSupabase / help-and-questions
4y ago
User ID in Jwt Payload
SupabaseSSupabase / help-and-questions
7mo ago