elysiajs / elysia-jwt

Plugin for Elysia for using JWT Authentication
MIT License
38 stars 16 forks source link

JWKS support #29

Open ThatOneCalculator opened 5 months ago

ThatOneCalculator commented 5 months ago

As jose supports JWKS for verification, it'd be great if this could too :)

acrois commented 4 months ago

It appears you can simply pass the JWKS as the "secret" parameter and achieve this. It is not documented, but essentially as long as secret is not a key it will get passed to the second parameter of jwtVerify, thus achieving this outcome.

Works as of 1.0.2 (67078d5).

The second parameter overloads to accept getKey: JWTVerifyGetKey

image

The type isn't properly exported by this library, but that doesn't stop me..

Here's an example: https://gist.github.com/acrois/8f9c6a0e2d3b6ee6744a0b7a87a2fa56

I added support for this in #30 which includes the type fixes you need to move forward without error.