AshAuthentication.Strategy.Totp.SignInPreparation (ash_authentication v5.0.0-rc.4)

Copy Markdown View Source

Preparation for the TOTP sign-in action.

Verifies the TOTP code against the user's secret and generates a token on successful authentication.

Replay Attack Protection

TOTP codes can only be used once. After a successful authentication, the last_totp_at field is updated to the code's timestamp to prevent replay attacks. This update is performed atomically with a filter condition to prevent race conditions where concurrent requests could both use the same code.

Summary

Functions

init(opts)

Callback implementation for Ash.Resource.Preparation.init/1.

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.