Skip to content

Commit f641471

Browse files
jchrisclaude
andcommitted
fix(dashboard): properly handle JWKS response structure for JWT verification
The JWKS endpoint returns {"keys":[{...}]} but the code was trying to use the entire response as a single JWK. This caused JWT verification to fail. Changes: - Parse JWKS response as {keys: JsonWebKey[]} - Use the first key from the keys array (standard practice) - Add validation to ensure keys array is not empty - Simplify code by removing unnecessary kid matching logic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6a7c705 commit f641471

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dashboard/backend/create-handler.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,16 @@ class ClerkApiToken implements FPApiToken {
7878
);
7979
if (rJwtKey.isOk() && rJwtKey.Ok().ok) {
8080
const rCt = await exception2Result(async () => {
81-
const jwsPubKey = await rJwtKey.Ok().json<JsonWebKey>();
81+
// Parse JWKS response
82+
const jwksResponse = await rJwtKey.Ok().json<{ keys: JsonWebKey[] }>();
83+
84+
if (!jwksResponse.keys || jwksResponse.keys.length === 0) {
85+
throw new Error(`No keys found in JWKS from ${CLERK_PUB_JWT_URL}`);
86+
}
87+
88+
// Use the first key (standard practice for JWKS endpoints)
89+
const jwsPubKey = jwksResponse.keys[0];
90+
8291
return (await verifyJwt(token, { key: jwsPubKey })) as unknown as ClerkTemplate;
8392
});
8493
if (rCt.isOk()) {

0 commit comments

Comments
 (0)