Referencing back to our id token from the previous section. If you’ve successfully logged in you may notice something on the URL string.
An example URL: we see that it contains the following:
- “id_token”
- “access_token”
These values are important as this is our challenge JWT token.
Now we need to find our private JWT token such that we can verify if this challenge token is correct.
To find it, go to https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json
- where userPoolId is from your Cognito pool that you’ve created.
- Region is where your Cognito service is deployed(for our usage is ap-southeast.2)
You should find a page looking like this:
We won’t go through how to validate, but the gist is to use a JWT decoder such as “jwt-decode” package and parse in the challenge JWT token details that you’ve received against this. Is relatively simples.
Hope this was informative and hope you’ve enjoyed this security workshop :)