Skip to content

Is it possible to decode a JWT without switching to the user? #2690

Discussion options

You must be logged in to vote

You could use the same static role: authenticator in each JWT - and then have a second field in the payload which contains the "real" role.

PostgREST would always change to the authenticator role first - which it already has anyway. No-op.

Then create a db-pre-request function, which checks the JWT payload, creates the real role if missing and finally does it's own SET ROLE <real-role>.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@tommyli
Comment options

@wolfgangwalther
Comment options

Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2689 on February 27, 2023 18:53.