You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: I am currently building a project (thriveondev.com, @thriveondev), in which the backend is completely written in plpgsql functions + @supabase. This is my first time attempting this approach, and so far, everything has been going well. I really like it and have been able to implement everything using PostgreSQL functions, except for one thing: signing a JWT token to enable push notifications using the Firebase API.
I have a pg_cron task that sends push notifications using the following query:
In this query, access_token is a JWT token signed with a Google private key. Unfortunately, I have not found a way to sign this token inside PostgreSQL, so I had to implement a separate API endpoint that signs it and returns it back to plpgsql:
It would be great if I could sign it within the PostgreSQL function. Overall, it's not a significant issue, but if it could be easily implemented, it would be greatly appreciated. Thank you.
The text was updated successfully, but these errors were encountered:
pgjwt only support HMAC-SHA symmetric key encryption because pgcrypto, the underlying core library, does not support RSA signing, only encryption. Unfortunately pgcrypto does not appear to be actively maintained and there seems to be no plan to update it to include signing, authenticated encryption, or any form of AEAD.
libsodium does provide public key signing (and many, many other features way beyond pgcrypto) but it does not support RSA, because the libsodium philosophy is to provide fast, efficient, modern ciphers, and RSA is none of those things. Instead libsodium provides Ed25519, a much more time and space efficient elliptic-curve based signature system.
So unfortunately until pgcrypto grows rsa signing support, or the jwt standard permits Ed25519 signing, there isn't any way to support what you want in-database.
In continuation of this post: https://twitter.com/ivanzotov/status/1696793534257307714?s=20 (cc @kiwicopple)
Context: I am currently building a project (thriveondev.com, @thriveondev), in which the backend is completely written in plpgsql functions + @supabase. This is my first time attempting this approach, and so far, everything has been going well. I really like it and have been able to implement everything using PostgreSQL functions, except for one thing: signing a JWT token to enable push notifications using the Firebase API.
I have a pg_cron task that sends push notifications using the following query:
In this query,
access_token
is a JWT token signed with a Google private key. Unfortunately, I have not found a way to sign this token inside PostgreSQL, so I had to implement a separate API endpoint that signs it and returns it back to plpgsql:It would be great if I could sign it within the PostgreSQL function. Overall, it's not a significant issue, but if it could be easily implemented, it would be greatly appreciated. Thank you.
The text was updated successfully, but these errors were encountered: