Repository navigation
Auth module: Verify tokens signed with ES384 and ES512 keys locally in GetClaims - #249
Open
QuintinWillison wants to merge 3 commits into
Open
QuintinWillison wants to merge 3 commits into
QuintinWillison wants to merge 3 commits into
Conversation
… the Auth server, without checking its signature, and how it defers one naming an algorithm it does not know. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…s other keys verifying locally. Co-Authored-By: Claude <noreply@anthropic.com>
QuintinWillison
marked this pull request as ready for review
December 5, 2026 02:41
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.
Fixes SDK-3346.
🤖 Claude's Summary
supabase/auth#2989 lets the Auth server sign access tokens with a P-384 key (
ES384), as it already could with a P-521 key (ES512). supabase/sdk#418 amended the cross-SDK spec forauth.session.get_claimsto have every SDK verify both locally, as it has them verifyES256.GetClaimssent a token of either algorithm to the Auth server, as it does any token it cannot verify itself, so a project signing with one of these keys paid a round trip on every call.A key on P-384 now binds
ES384and one on P-521 bindsES512, under the rulesES256already follows. The key'salgmust agree with itscrv, or the token goes to the server as before. The token's header must name the bound algorithm, and the signature must berthensat the width of the curve, 96 bytes forES384and 132 forES512. The three algorithms share one path, which reads the curve, hash and width of each from a table. Go's standard library supplies every curve and hash, so no dependency is added.Two things change for a project that signs with one of these keys, both already true of local verification. A token is no longer checked against its session, so one whose user has signed out passes until it expires, where before the server refused it.
GetUserremains the call for a decision that depends on the session. And a failed download of the JWK Set now fails the call, where before such a token never needed the download.The first commit pins today's behavior in tests that pass against it: a token of either algorithm reaches the user endpoint and never the JWK Set, even when the published key did not sign it. It also pins that a token naming an algorithm the client does not know,
ML-DSA-65here, goes to the Auth server and never fails for that, which the spec asks for so that a project can adopt a signing algorithm an SDK predates. The second commit adds the support, flips what the cases for the two algorithms expect and leaves that last one as it is. The third pins one more thing that holds before and after: a published key the client cannot verify with leaves the set's other keys verifying locally. A JWK Set holds such a key while a project prepares a rotation to an algorithm the client does not know.The second commit also verifies two signatures this codebase did not make. One is the
ES512example of RFC 7515, appendix A.4. The other is anES384token that Node.js signed through the Web Crypto API, since the RFC has noES384example. The script that made it sits beside it in the test. Before printing, the script checks the token with theimportKeyandverifycalls supabase-js makes ingetClaims, given the algorithm object supabase/supabase-js#3003 mapsES384to.No integration test comes with it, because the local stack cannot sign with such a key yet: the Supabase CLI that runs the stack takes RS256 and ES256 signing keys alone, and the Auth version it runs predates supabase/auth#2989. So this change has yet to verify a token that an Auth server signed with one of these keys.