Skip to content

Single use access token after a step-up authentication

0

I am currently designing a custom authentication flow to fulfil a step-up authentication flow. Part of this, I am intending to use the custom authentication lambda triggers. after validating the required custom challenge, I would want add a claim to the token to indicate that the step-up is completed. The token I want should be used only for a specific transaction and any follow up actions performed by the user should not use the same token I issued. How do I achieve this.

trying to achieve something like the aws sample here, but would want to ensure the token is used only for one transaction.

2 Answers
5

You may interest on below and please note Cognito doesn't natively support one-time-use tokens out of the box yet:

  1. Custom Claim Injection After the user completes the step-up challenge, use the DefineAuthChallenge and CreateAuthChallenge Lambda triggers to inject a custom claim like "step_up": true into the token via the PreTokenGeneration trigger.
  2. Token Binding to Transaction Include a unique transaction ID in the token (e.g., "txn_id": "abc123"). This ID should be generated server-side and stored in a secure, short-lived store like DynamoDB with a TTL.
  3. Token Validation on API Call When the token is used to perform the sensitive transaction: o Validate the step_up claim. o Check the txn_id against your store to ensure it hasn’t been used. o If valid, mark it as used (e.g., delete or flag it). o If already used, reject the request.
  4. Short TTL for Token Expiry Set a very short expiration time (e.g., 5 minutes) for the token to reduce the window of misuse.

https://aws.amazon.com/blogs/security/implement-step-up-authentication-with-amazon-cognito-part-1-solution-overview/

EXPERT

answered a year ago

0

The token content, claim values can't be changed once the token is issued. There is a jti value inside each access token and it's unique identity of the token. https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-the-access-token.html

To indicate a token has been used, your lambda can store the used tokens' jti value within a DB. Always check token jti value against that DB while validating the tokens to avoid tokenreplay. It's a good tip to set TTL to the DB items which can be the same as the token's expiration time.

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.