integrating with postgres rls (supabase)
hi. i'm trying to migrate off of supabase auth so i wanted to go with better-auth. my question is, how could i correctly use the JWT integration to setup RLS auth? do i need to always fetch the endpoint to get the JWT token, or could i get it auto-provided every time? that would be much simpler for setup
i need to setup RLS for maybe two days with supabase and then i'm migrating to neon (want auth and db to be staggered, don't want a big screwup to hit all at once)
7 Replies
@daveycodez might help but check the jwks plugin
https://www.better-auth.com/docs/plugins/jwt
JWT | Better Auth
Authenticate users with JWT tokens in services that can't use the session
yeah i saw that plugin + the usage davey has (https://discord.com/channels/1288403910284935179/1296058482289676320/1337526387967266847), just wondering how to set it up
what complicates it more i feel is me migrating auth and then db - it makes sense to do like this but makes some parts more annoying / painful
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
hell yeah, thank you
hey @daveycodez, do you by chance have any knowledge on how to get supabase working with better-auth? i've looked at your package, but i have no idea how to get supabase to cooperate with the better-auth tokens - do you know how by chance?
i have this so far
turns out i just had to forge my auth token on an api route and put some cache headers on it, kinda sick tbh
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
yeah i know that's the next step - just need to setup proper auth so that i can migrate off supabase part by part
@daveycodez i've been looking more and more into this, saw the issue here and convos in discord. how would you ideally have the jwt support work?
like it's just stored in the session or something so it can be used on both the client and server in the ideal case, and can be revalidated every 5m or something
Unknown User•7d ago
Message Not Public
Sign In & Join Server To View