Cognito: Key Rotation

0

Please confirm if Cognito rotates the keys used to sign ID and Access tokens. The docs do not specify.

If they are rotated, how often?

MT
질문됨 2년 전389회 조회
1개 답변
0

Yes the document does not specify whether the keys are rotated. However, Cognito service may need to rotate the keys if required.

Hence, we recommend you to cache each key present in JWKS URI [1] against "kid". When you have a token to validate, then first check the "kid" present in the header of that JWT token. If you have a key with that "kid" in your cache then use that key. Otherwise, query the JWKS URI to fetch recent keys and update your local cache with the new "kid". This will help to make the application more robust and you will be able to handle the scenario if the public key is rotated in unforeseen future.

--References--

[1] The format of the JWKS URI is following (replace {region} with AWS region and replace {userPoolId} with the ID of your user pool): https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json

AWS
지원 엔지니어
Tarit_G
답변함 2년 전
  • Where should we cache them? Users can find the region and user pool ID with a bit of snooping, so the JWKS is essentially public. Would hardcoding them be ill-advised?

  • You need to cache it in server side of your resource server (means where you are performing JWT validation before providing access to your secured resources).

  • Thank you but I meant what caching method/service? Right now I'm trying S3 but it is convoluted compared to just downloading the JWKS each time as I have been doing. This is in a Lambda authorizer for APIGW written in Go. What did you have in mind for caching?

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

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

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

관련 콘텐츠