Files
floci/docs
Niels Kootstra 8b9f441bb4 fix(cognito): expire auth challenge sessions (#4417)
* fix(cognito): expire auth challenge sessions

InitiateAuth and RespondToAuthChallenge session tokens for SRP, custom
auth, and USER_AUTH never expired, so an abandoned challenge session
lingered in memory forever and could still be completed long after
AWS would have rejected it. Track when each session was issued and
reject expired ones with the NotAuthorizedException Cognito returns
in that case, purging expired entries whenever a new one is created.

AWS defaults AuthSessionValidity to 3 minutes (configurable 3-15 via
CreateUserPoolClient); UserPoolClient does not yet store a per-client
override, so every client uses the 3 minute default for now.

* fix(cognito): stamp custom auth tokens when they are issued

A CUSTOM_AUTH session's issue time was recorded before the
DefineAuthChallenge and CreateAuthChallenge triggers ran, so a slow
trigger shortened the session handed to the client. The issue time
also lived on the flow state shared across rounds, so minting the next
round's token refreshed the old token while it was still in the map.

Each custom auth token now carries its own issue time, stamped when it
is stored, and every issuance path (including both continuations)
purges expired tokens first.

* style(cognito): brace the custom auth session lookup

* test(cognito): use the shared MutableClock

* docs(cognito): document auth challenge session expiry

* chore: rerun CI

* chore: rerun CI
2026-09-26 16:10:19 -05:00
..
2026-03-15 17:43:56 -05:00