Skip to content

fix(auth): pass alg to importJWK for jose v6 compatibility with Auth0…#1097

Open
cameron-michie wants to merge 1 commit into
masterfrom
fix/pass-header-alg-to-importJWK
Open

fix(auth): pass alg to importJWK for jose v6 compatibility with Auth0…#1097
cameron-michie wants to merge 1 commit into
masterfrom
fix/pass-header-alg-to-importJWK

Conversation

@cameron-michie
Copy link
Copy Markdown

@cameron-michie cameron-michie commented May 11, 2026

Bug fix

What is the current behavior?

Any authenticated Storage request fails with HTTP 403 when the configured JWKS contains RSA keys that omit the "alg" field.

The error thrown is from here: "alg" argument is required when "jwk.alg" is not present

jose v6 removed algorithm inference from importJWK(). It now requires either jwk.alg to be set on the key object, or the algorithm passed explicitly as the second argument. Storage was calling importJWK(jwk) without either, causing jose to throw before the key could be imported.

What is the new behavior?

importJWK is called as importJWK(jwk, header.alg)

Additional context

n/a

Copilot AI review requested due to automatic review settings May 11, 2026 13:07
@cameron-michie cameron-michie requested a review from a team as a code owner May 11, 2026 13:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts JWT verification key import to be compatible with jose v6 when consuming JWKS entries (notably from Auth0) that may omit algorithm metadata, by passing the token header algorithm into importJWK.

Changes:

  • Pass header.alg into importJWK when importing an asymmetric JWK for verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/internal/auth/jwt.ts
Comment on lines 90 to 94
// couldn't find a matching JWK, try to use the secret
return encoder.encode(secret)
}
return await importJWK(jwk)
return await importJWK(jwk, header.alg)
}
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25672082097

Coverage increased (+0.03%) to 74.29%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file 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: 10284
Covered Lines: 8047
Line Coverage: 78.25%
Relevant Branches: 5943
Covered Branches: 4008
Branch Coverage: 67.44%
Branches in Coverage %: Yes
Coverage Strength: 410.88 hits per line

💛 - Coveralls

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants