Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

security - Cognito - how to refresh token using SDK when app client has secret

I'm implementing backend for web application. My app client in AWS Cognito has secret, and I'm using it in InitiateAuth requests. I need username to calculate SECRET_HASH which should be used in those requests.

This SECRET_HASH works in the login/sign-in flow. Received tokens are sent to the frontend and idToken is stored in the React state and refreshToken as a cookie. If the user refresh the page the idToken is removed and new tokens should be received from the endpoint for refreshing tokens (using cookie). It's impossible because I need username for creating the SECRET_HASH.

I can store the idToken as a cookie too, but it looks like a less secure option. I can use for example Redis on the backend side to store mapping of refresh token to the username, but it looks like overengineering.

What is the best way to handle this? Should I send both tokens for refreshing or create mapping for username and refresh token on the backend side? Or maybe I'm missing something in the SDK and the REFRESH_TOKEN flow should be possible without username?

question from:https://stackoverflow.com/questions/65858353/cognito-how-to-refresh-token-using-sdk-when-app-client-has-secret

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...