Amplify Cognito Auth JS Library keeps all tokens in localStorage?

0

Recently started building a SPA. I'm using the official AWS stand-alone Amplify javascript library for Auth. After deploying my SPA and logging in, I noticed that all of my tokens are persisted in local storage in the browser.

For example:

key
CognitoIdentityServiceProvider.1k90vt58oc1v7kfme68th8kdf0.myuser.accessToken
CognitoIdentityServiceProvider.1k90vt58oc1v7kfme68th8kdf0.myuser.refreshToken
CognitoIdentityServiceProvider.1k90vt58oc1v7kfme68th8kdf0.myuser.idToken

I'm fairly new to the frontend auth, but everything I've read has claimed that this is poor security. For example:

auth0.com: Using browser local storage

Here’s Why Storing JWT in Local Storage is a Disastrous Mistake

Best Practices for Storing Access Tokens in the Browser

Is this something that AWS is failing to account for?

1 個回答
1
已接受的答案
profile picture
專家
已回答 1 個月前
profile picture
專家
已審閱 1 個月前
profile picture
專家
已審閱 1 個月前
  • Do you know if the withAuthentication wrapper handles token refreshes automatically for me?

  • Amplify will keep active session for as long as it can, but I don’t think it will automatically refresh the token. Typically I did call Auth.currentSession() which would then renew to token automatically

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南