-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Can we throw a better error message for JWSError JWSInvalidSignature
?
#1840
Comments
We need a secret of at least 32 characters, as stated in the docs. However, we should try to throw a better error message in that case - possibly already at startup. |
Thanks for clarifying however I tried giving a secret longer than 32 characters and gave a restart. But still the issue persists. Secondly , I also tried generating a token on jwt.io using this secret and I got a jwt as below: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoibWVkaWd5X2FkbWluX3JlYWRfb25seSIsImV4cCI6MTYyMDEwNDI4MH0.LmtOC1igJ1-ilu0ra3d99FnxlbJviJpFnNlLJ5UV1Ug Using this in my get request fails with the same error |
Did you just restart the container or did you recreate it? Restarting the container will not take changes to the docker-compose file in account - you need to re-create it, e.g. with Using the same secrets you posted and some JWTs that were signed with the same token, I get:
As stated earlier, we should try to throw a better error when the token is too short - and not just report an invalid signature for every jwt we receive. But other than that, I think everything is OK, and you just need to make sure the environment variable you set really reaches PostgREST. |
I had this same issue. The docs show various ways to store the JWT secret, but Postgrest only searches for it in a few places when validating a token. Setting the env var |
We cannot throw a precise error "message" regarding the 32 chars min because we also accept JWKS in the However we can add a "hint" with different recommendations. |
I have the similar issue. When I set the |
|
JWSError JWSInvalidSignature
?
Another case where I hit this, in case it helps others: running locally in dev mode and switching between two backends, I did not reload the webpage. The It was not clear to me that the wrong token was being sent until I inspected the JWT in the request. (i.e. I was sending a token for user |
I guess in that case, it could help to add the received token as a json representation to the error message? That should have lead you on the right track much quicker, correct?
Can we not change the parser here ... postgrest/src/PostgREST/Config.hs Lines 412 to 420 in 9021c96
... to something like this?
|
It definitely would have! But I'm also not sure whether everyone would be happy with that solution. I would think the user has access to the JWT so exposing the data shouldn't be a concern - just wanted to note that there may be people bothered by exposure of data where it was not before 🤷♂️ I don't know what standards around JWT behavior / exposure are though Interestingly and as a small corollary that I forgot about - |
Yeah. Whoever is bothered by decoding the byte64 string and displaying it for better error message - doesn't understand how JWTs work. "Encoding" something in the JWT is by no means "secret". Everything in the JWT is public and this is signed only. So if at all, it would lead to more education for those who ask :) Although there is one thing that we should not do: And that is returning the signature of the JWT in the error message. We should only return the payload. This way ppl can easily copy the error message to somewhere else... e.g. to our issue tracker, without risk. |
@taimoorzaeem no, I'm not, close away |
I think there's some more valuable details in here that are not part of #3600, so we shouldn't close it, yet. |
Hi,
I am using Postgrest on docker and the below is my docker compose -
The login user is the authenticator role and I have also specified a jwt-secret that is being used by a function in Postgres that uses the sign method of pgjwt extension to generate the jwt.
However, when I try to
GET http://10.10.11.124:4432/<api name>
with the authorization header set to Bearer I get the error below:Please let me know where could I possibly be going wrong.
The text was updated successfully, but these errors were encountered: