79124444

Date: 2024-10-25 06:14:02
Score: 0.5
Natty:
Report link

Storing the JWT tokens in local storage can be simple and easy to implement, but it is not recommended for security reasons. When you store the tokens in local or session storage, they can be accessed through any Javascript on your web page, which means it is vulnerable to attacks such as cross-site scripting. If an attacker can execute scripts on your web page, he can impersonate the user by making requests to your API with the stolen token. according to me the best approach to store your tokens would be using httpOnly cookies(Access token and Refresh token approach). eg:Set-Cookie: access_token=<your_token>; HttpOnly; Secure; SameSite=Strict; how it works:

  1. The server sends 2 httpOnly cookies, one with an access token and the other with a refresh token. 2)when the access token expires, the Flutter web app uses the refresh token to request a new one from the backend. 3)If the refresh token is valid the backend generates a new access token. (the user does not have to log in again).

Hope this answer helps u.....

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Bhuvan A