Skip to content

Integrating a custom auth flow with Supabase client while taking advantage of RLS #1849

Answered by awalias
rkhatkhede asked this question in Questions
Discussion options

You must be logged in to vote

hey @rkhatkhede !

yes you can mint your own JWTs from anywhere, you need to grab the jwt_secret from the dashboard:

in Settings > API

and then you can mint your own tokens anywhere using something like jsonwebtoken lib

var jwt = require('jsonwebtoken');
var token = jwt.sign({
  "sub": "1234567890",
  "name": "John Doe",
  "iat": 1516239022,
  "someclaim" : "VaaVaaVoom"
}, jwtSecret);

(you can test this on https://jwt.io/ also)

and set it as a header in supabase-js in the way that you mentioned:

const headers = { Authorization: 'Bearer USER_JWT' }
const supabase = createClient( "https://REF.supabase.co",  "KEY", { headers });

additionally you can create your own RLS helper functions to pu…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@darlanjunior
Comment options

@dotlouis
Comment options

@alexanderwe
Comment options

@ChuckJonas
Comment options

Answer selected by awalias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants