Skip to content

feat(auth): verify ES384 and ES512 JWTs locally in claims - #1931

Draft
grdsdev wants to merge 2 commits into
mainfrom
guilhermesouza/sdk-3343-supabase-swift-verify-es384-and
Draft

grdsdev wants to merge 2 commits into
mainfrom
guilhermesouza/sdk-3343-supabase-swift-verify-es384-and

Conversation

@grdsdev

@grdsdev grdsdev commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

What

AuthClient.claims() now verifies ES384 and ES512 access tokens on the device, as it already does for ES256, RS256, and EdDSA. Before, these tokens always took the server fallback.

  • JWTVerifier binds a JWK with kty: EC and crv: P-384 to ES384, and one with crv: P-521 to ES512. As before, a JWK whose alg does not match its curve is not bound and takes the fallback. The algorithm comes from the key, never from the token header.
  • Verification uses swift-crypto P384.Signing / P521.Signing on the raw r || s signature (96 / 132 bytes), with SHA-384 / SHA-512. No new dependency.
  • JWK+EC.swift builds the P-256, P-384, and P-521 keys through one helper that checks the coordinate length (32 / 48 / 66 bytes).
  • No public API change.

Spec: supabase/sdk#418 (get_claims.md, "Signing algorithms").

Tests

  • Unit (JWTVerifierTests): a valid token verifies for both curves. A tampered payload, another key, and a short signature fail. An alg/crv mismatch takes the fallback. Bad coordinates and an off-curve point fail closed.
  • AuthClientTests: claims(jwt:) end to end with an ES384 and an ES512 JWKS.
  • Integration: claimsVerifiesES384LocallyAgainstJWKS and claimsVerifiesES512LocallyAgainstJWKS run against a new supabase-ecdsa project. It starts once per algorithm with a key from scripts/gen-ecdsa-signing-key.sh, the same way the EdDSA test works. CI runs ES512 first.

Local results:

  • Full unit suite passes. Auth: 904 tests, 6 known issues that were there before.
  • claimsVerifiesES512LocallyAgainstJWKS passes against a live stack.
  • claimsVerifiesES384LocallyAgainstJWKS fails, and this is expected: sign-up returns 500 error generating jwt token, because no Auth release signs ES384 yet.

Server behavior

  • ES512: Auth signs with it (GetSigningAlg). Confirmed with the live integration test.
  • ES384: signing merged in Support ES384 JWTs auth#2989. It is not in a stable release yet. Unverified until the release, and the ES384 integration test stays red until then.

Deviations from the plan

  • Added an end-to-end claims(jwt:) test in AuthClientTests+SessionsAndClaims.swift, which the plan did not name.
  • The plan deferred the integration tests to a follow-up. They are in this PR instead, with ES384 expected to fail until the Auth release.

Draft until an Auth release with ES384 signing is in the local stack.

Fixes SDK-3343
Fixes SDK-3349

Bind P-384 keys to ES384 and P-521 keys to ES512, and verify the raw
r||s signature with swift-crypto. A JWK whose alg disagrees with its
curve still takes the server fallback.

Fixes SDK-3343
Run claims() against a local Auth server that signs with a P-384 or a
P-521 key, in a new supabase-ecdsa project that starts once per
algorithm. The ES384 test fails until an Auth release includes ES384
signing (supabase/auth#2989); ES512 runs first so it still reports.

Refs SDK-3349
@github-actions github-actions Bot added the auth label Dec 4, 2026
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 47321440103

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.006%) to 96.402%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: 34 of 34 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18260
Covered Lines: 17603
Line Coverage: 96.4%
Coverage Strength: 7143.06 hits per line

💛 - Coveralls

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants