#How to support Key Rotation in NestJs?

5 messages · Page 1 of 1 (latest)

subtle perch
#

Hi, I am working on the project that has one resource server and multiple other server. I want to authenticate using JWT(RS256). I want to support key rotation in the resource server ( planned to expose jwks on an endpoint ). How can I do it?, Thanks.

haughty orchid
#

Pretty sure the jsonwebtoken package that @nestjs/jwt uses under the hood supports jwks by default

subtle perch
#

Thanks,
Sorry I think the package doesn't have one(https://github.com/auth0/node-jsonwebtoken). But even though i use some other package like https://www.npmjs.com/package/rsa-pem-to-jwk, how can i maintain 2 keys ( current and future ) and expose it to other servers ?, Thanks.

frail hare
#

@subtle perch when you are using openid connect, you can use the jwk_uri where you can offer multiple keys that can be used. It is important that you are using a jti in your key, so you know which key should be used when verifying the signature (it should be the kid in the JWT)