ra-in-memory-jwt
Probably by routine or by Stack Overflow syndrome, we often use a JSON Web Token(JWT) to manage this authentication between our frontend apps and their API. For convenience, we store this token in the browser's localStorage. But this is not a good practice, as Randall Degges explains in his article "Please Stop Using Local Storage". For the most curious, here is an example of how "Stealing JWTs in localStorage via XSS".
But then, how to use a JWT to manage authentication in a more secure way? ra-in-memory-jwt is an implementation of a solution proposed by the Hasura team in their article The Ultimate Guide to handling JWTs on frontend clients.
You can find a detailed explanation of this implementation on the blog post Handling JWT in Admin Apps the Right Way.
Installation
From npm
npm install ra-in-memory-jwtFrom scratch
The use of ra-in-memory-jwt is strongly linked to your API. Rather than using the npm package and the configuration options (see next part), you will probably save time to recreate the innMemoryJWT.js file from the original file. And it will be one less dependency for your project!
Configuration
ra-in-memory-jwt must know the API endpoints to refresh the JWT. The default value is /refresh-token, but you can change it with the setRefreshTokenEndpoint method:
inMemoryJWT.setRefreshTokenEndpoint('http://localhost:8001/another/refresh-token-endpoint');Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
To learn more about the contributions to this project, consult the contribution guide.
Maintainer
License
ra-in-memory-jwt is licensed under the MIT License, courtesy of Marmelab.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
