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
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
profile picture
전문가
검토됨 2달 전
  • 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

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인