Add JWKS Support - #112
Merged
Merged
Conversation
Contributor
Author
|
Not sure if anyone has seen this PR so far. I'd like to understand if this is a move in the right direction. And let me know if Copilot reviews above need to be addressed. |
Contributor
Author
|
Hello @diogob, any chance you can have a look at this any time soon? |
Owner
|
Hi @yaroslav-ilin tahnks for the PR. Sorry, I missed the notification about this PR and just saw it now. I'll take a look tomorrow. Don't worry about the co-pilot review, I believe github enabled this feature by default without my consent. |
Owner
|
Thanks again for the PR @yaroslav-ilin . Will prepare a release later this week. |
Contributor
Author
|
Thanks 🎉 Regarding Copilot it's probably a setting on my side 😊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Disclaimer: I have no prior experience writing Haskell and most of this contribution is driven by AI.
Added support for JWKS (JWK Sets). JWK was already supported by the current version of postgres-websocket, although not very well documented. It works by specifying
PGWS_JWT_SECRET=@/run/secrets/jwk.json. However this only supports single key right now. JWKS (multiple keys) is supported by the underlyingjoselibrary and this pull request extends its use in postgres-websocket. This change should make it compatible with PostgREST implementation which already supports JWKS withPGRST_JWT_SECRET=@/run/secrets/jwks.json.It first tries to parse the secret as JWKS, then as single JWK object and then finally as HMAC fallback for backwards compatibility.
Changes
Claims.hs:
parseJWK→parseSecret: Now handles JWKSet, single JWK, and plain string secrets with fallback logicjwtClaimssignature: AcceptsJWKSetfor verification (supports automatic key selection bykid):: SignedJWTfor jose-0.12 compatibilitypostgres-websockets.cabal: Bumped jose from
< 0.12to< 0.13cabal.project: New configuration file with
constraints: ram < 0(workaround for jose#138)ClaimsSpec.hs: 3 new tests
Build & Test
Result: All 10 tests pass (7 existing + 3 new JWKS tests)