WangHansen / jwt-auth

JWT authentication library with built-in key rotation and token revocation function
https://github.com/WangHansen/jwt-auth
MIT License
17 stars 4 forks source link

Rethink load / save of keys (dont load / save all together) #22

Open MickL opened 8 months ago

MickL commented 8 months ago

Nice library! I just have concerns that it loads and saves all keys at once. This might work for a few thousand keys bit it cant scale into infinity. First of all we cant hold an array of infinite size in Node.js depending on the memory size of the server instance. Second when using a database like MongoDB getting all keys out of the database could be too much as well.

Wouldnt it make more sense to load each key from the storage just in time when it is needed?

WangHansen commented 8 months ago

Yeah that is great idea. I have not been working on this library for a while so feel free to fork and adjust the code accordingly based on your needs. Are you trying to build an auth solution. Maybe you can check out Lucia Auth