Skip to content

Auth module: Verify tokens signed with ES384 and ES512 keys locally in GetClaims - #249

Open
QuintinWillison wants to merge 3 commits into
mainfrom
sdk-3346-get-claims-es384-es512
Open

QuintinWillison wants to merge 3 commits into
mainfrom
sdk-3346-get-claims-es384-es512

Conversation

@QuintinWillison

Copy link
Copy Markdown
Member

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 for auth.session.get_claims to have every SDK verify both locally, as it has them verify ES256. GetClaims sent 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 ES384 and one on P-521 binds ES512, under the rules ES256 already follows. The key's alg must agree with its crv, or the token goes to the server as before. The token's header must name the bound algorithm, and the signature must be r then s at the width of the curve, 96 bytes for ES384 and 132 for ES512. 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. GetUser remains 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-65 here, 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 ES512 example of RFC 7515, appendix A.4. The other is an ES384 token that Node.js signed through the Web Crypto API, since the RFC has no ES384 example. The script that made it sits beside it in the test. Before printing, the script checks the token with the importKey and verify calls supabase-js makes in getClaims, given the algorithm object supabase/supabase-js#3003 maps ES384 to.

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.

QuintinWillison and others added 3 commits December 5, 2026 02:04
… 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>
…s other keys verifying locally.

Co-Authored-By: Claude <noreply@anthropic.com>
@QuintinWillison QuintinWillison self-assigned this Dec 5, 2026
@QuintinWillison QuintinWillison added auth Relates to the auth module. sdk-spec-alignment A canonical capability specification has changed in supabase/sdk, to which we need to conform. labels Dec 5, 2026
@QuintinWillison
QuintinWillison marked this pull request as ready for review December 5, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Relates to the auth module. sdk-spec-alignment A canonical capability specification has changed in supabase/sdk, to which we need to conform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant