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

Is it safe to store refresh token in localstorage? #168

Open
pranavxc opened this issue Sep 9, 2020 · 1 comment
Open

Is it safe to store refresh token in localstorage? #168

pranavxc opened this issue Sep 9, 2020 · 1 comment

Comments

@pranavxc
Copy link

pranavxc commented Sep 9, 2020

Correct me if I am wrong, looks like refresh_token and access_token are stored in localstorage in the browser.

Once gaining access to these refresh_token, an attack like cross-site scripting (XSS) is possible. So the attacker can generate new access_token using refresh_token.

  1. Is there any option to prevent this kind of attack?
@dustincrogers
Copy link
Contributor

Hi @pranavxc:
That is correct. Here are most of the options in a ordered list:

  1. The first option would be a no refresh token, and just an access token that may or may not expire
  2. (CURRENT) Use refresh tokens stored in local storage
  3. Store access token in Http-Only cookie, and encrypt cookie using server side stored key. use "implicit flow" when re-authentication occurs
  4. Same as 3, but also include CSRF token
  5. (BEST) OAuth 2.0 Authorization Code Flow (PKCE)

Some of these options would require functionality outside of gotrue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants