Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should passport-http-bearer read token from session cookie? #45

Closed
lvbeck opened this issue Feb 18, 2016 · 1 comment
Closed

Should passport-http-bearer read token from session cookie? #45

lvbeck opened this issue Feb 18, 2016 · 1 comment
Labels
discussion Conversation that isn't an issue or pull request

Comments

@lvbeck
Copy link

lvbeck commented Feb 18, 2016

I know it looks like a stupid question, usually a bearer token is stored in LocalStorage and send with request which contain the Authorization header field. However recently I read this article:

https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage

Above article argue that localStorage shouldn't be used because of XSS attacks and suggests using session cookie(with HttpOnly flag) to store the jwt token. This method seems to be reasonable.

in this case, javascript cannot read the cookie (which contains access_token) since HttpOnly flag is set, hence i cannot append the token in the request authorization header.

So any possible that passport-http-bearer will also read token from session cookie in future?

@AOlefirenko
Copy link

@lvbeck I agree with you. I would like to use cookie for storing JWT. There are several benefits.
First it's simpler because browser automatically adds a token to each request.
Second When using social logins to authenticate users (passport-facebook/passport-google) you need to pass new token with redirect response. I know two options how to perform it: add token to query string or add record to cookie. So in this case using cookies is simpler way as well.
It would be very nice to add this feature. I've created a pull request #46

@jaredhanson jaredhanson added the discussion Conversation that isn't an issue or pull request label Oct 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Conversation that isn't an issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants