jwt-auth icon indicating copy to clipboard operation
jwt-auth copied to clipboard

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

Open MickL opened this issue 2 years ago • 1 comments

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?

MickL avatar Oct 16 '23 12:10 MickL

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

WangHansen avatar Oct 16 '23 17:10 WangHansen