-
Notifications
You must be signed in to change notification settings - Fork 60
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
Verify fails when JSON payload contains characters dash or colon #29
Comments
I think I figured it out, by decomposing the query.
We can see the CURRENT_TIMESTAMP is earlier than the moment I sampled the current server-side timestamp The test So the test works or not depending on the rounding, which depends when things happen exactly. Pfiou! PS: And this has nothing to do with the characters or not in the payload, as I thought it was... |
For reference, here's the query I used to troubleshoot this (
PS: The 1 or 2 in function names are an artifact of my un-extension conversion |
Hi,
First, thanks for this extension. I use it for (FAT, native) client applications connected to PostgreSQL using libpq, to capture in a secure manner the LOGIN and current ROLEs of the client connection. So that those applications can contact over HTTP a mid-tier server that will do on their behalf (in its own higher privileged connection, after checking the roles against an internal security model) DDLs that the client connections cannot do directly (they can only do DMLs).
I unit tested my transposition of your code, and things were fine.
But then in production it was failing.
I tracked it down to ROLE names with embedded dash
'-'
and colon':'
characters (spaces OTOH were OK).Those role names appear in the JSON payload used to sign the JWT.
The payload (and thus role names) come back OK on verify.
BUT... the JWT is reported as invalid.
I'll try to track it down on my own, but since I'm not much of a pg/plSQL dev, you may get there before me :)
Here's the exact JSON payload (and random secret) I'm using, in case that helps
Update: I may have jumped the gun. Even with
-
and:
replaced by_
in the payload, it sometimes failed. Earlier I thought it ran fine, but repeatedly calling a test that just signs and verify, fails sometimes. Given that I manually add 600s tonbf
to set theexp
it can't be an expired token. So something else is afoot...PS: Note that I've adapted your code from an extension, to just functions I create in my own schema. Because you cannot add extensions in cloud-managed PostgreSQL instances, AFAIK. So it is possible the error is in my transposition of your code as a non-extension.
The text was updated successfully, but these errors were encountered: