-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read jwt-secret from the database #1429
Comments
@carragom Hey there. From your example I'm not sure how your For the latter case, since postgrest supports reading from a file in the jwt-secret you could do something like: ## Having the postgrest.conf like
jwt-secret = @./mysecret
## Then on deployment
psql postgrest_test -A -t -X -c "select current_setting('app.jwt.secret');" > mysecret Then you'd have to restart postgrest since there's no unix signal yet for reloading the jwt-secret(#1119). |
@steve-chavez that makes a lot of sense. Will try it that way. |
That being said, we could add a way to get the jwt-secret directly from the db. There are deployments that have the jwt-secret in a table, like in PostgREST/postgrest-docs#28. Maybe we can have another config param for this, that could get the secret from a table or view(this one could obtain the secret from a GUC). |
That would be awesome |
Have the same need. The secret is generated when deploying the app and already needs to be protected in the db.
|
@drorm Good points. I'll reopen for further discussion. |
Even if pgrst reads the secret from the db, the secret won't be automatically reloadable because we will need to cache it. So for this to work we'd need to also clear #1119. |
Use asymmetric crypto ed25519 etc, with asymmetric keys postgrest need only public key. |
Environment
Description of issue
Hi, not sure if this is a question or a feature request but here it goes. I'm using SQL User Management as described in the docs and everything is working as expected.
Whenever I deploy my database schema using migrations a random JWT secret gets created with a statement like this:
Since the app is in development the schema gets re-deployed quite often and a new random secret gets installed on the database. Every time this happens I have to edit my
postgrest.conf
and set thejwt-secret
parameter to the result of the following query:If this is not done, the authentication does not work. This is expected of course since the signer (a database function) uses a different secret that PostgREST which is the one that verifies the JWT.
I was wondering if there was a way to tell PostgREST to read the
jwt-secret
from the database instead of having it hard coded in the config. Or maybe there is some other clever (hopefully simple) way to keep those two values in sync.Thanks for your time and this great tool.
The text was updated successfully, but these errors were encountered: