Best way to verify signature of ID Token from Cognito

0

I have a lambda that gets username from the ID token passed to it. But I want to know the best practice safety mechanism to put in place security concerns are addressed. So how can I verify the Id_token is from the same user the ID Token is supposed to be coming from. I know calling the getuser api with acesstoken is not a good method. What should be the best way here to verify the id?

1개 답변
1
수락된 답변

Hi,

the best way to verify the id token is to use an OIDC, OAuth2, or JWT library.

those library will get the public key from the JWKS endpoint associated with the issuer of the token and validate the signature. Then it will validates that the token is in its valid time boundaries (not before, not after). You can generally add additional checks on claims values, scopes, and client id value.

We provide the following library to help you with that: https://github.com/awslabs/aws-jwt-verify

Jeff

AWS
답변함 10달 전
profile picture
전문가
검토됨 10달 전

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

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

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

관련 콘텐츠