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

Allow a different storage.

Open rawnly opened this issue 3 years ago • 7 comments

Hello, I would like to store my credentials inside a cookie. I need them available for SSR reasons. Having the ability to specify a custom storage would be nice.

It could be done extending the existing Storage interface and adding it to the config object.

rawnly avatar Jun 06 '22 14:06 rawnly

I agree that cookie support is needed. It's generally considered best practice because of HttpOnly and friends. Which I didn't know when I wrote this module.

revmischa avatar Jun 06 '22 20:06 revmischa

I took a look at the code (which I contributed in the past) and I think that for such a radical change it the structure has to reviewed to be more permissive… if u’re interested I can try something in the weekend.

rawnly avatar Jun 08 '22 00:06 rawnly

Sure maybe a 2.0 version would make sense

revmischa avatar Jun 08 '22 01:06 revmischa

Inspired by @jetbridge, I created an http-client.js that stores, clears, transmits and automatically refresh JWT authentication tokens. Supports both localstorage and cookie storage. Check it out here

prince272 avatar Aug 04 '22 19:08 prince272

You should consider opening up a pull request :-)

mvanroon avatar Aug 05 '22 08:08 mvanroon

Okay sure. But the issue is, I'm not familiar with TypeScript. I was searching for js/ts library that handles jwt operations without the need to do that manually and I found this awesome library with great technic of handling jwt.

prince272 avatar Aug 05 '22 09:08 prince272

What about a general Storage interface so the user can configure it as preferred from the interceptor? (Like the refresh function)

rawnly avatar Aug 05 '22 19:08 rawnly

Made a PR that would allow usage of cookies as well: https://github.com/jetbridge/axios-jwt/pull/48

greenyas avatar Dec 05 '22 16:12 greenyas

this one and #45 can be closed once #48 is released :)

rawnly avatar Jan 10 '23 00:01 rawnly