SMS OTP is a post-launch 2FA method that sends a one-time code to a verified phone number as the second factor. It implements the TwoFactorProvider contract.
Flow
- When a 2FA challenge is triggered for a user with SMS OTP enabled, a short-lived numeric code is generated, hashed, and stored against the user with an expiry
- The raw code is sent to the user's verified phone number via a configurable SMS provider
- The user submits the code at the 2FA validation endpoint
- The submitted code is verified against the stored hash and checked for expiry — on success the code is consumed and a
RawToken is issued
A code that has expired or already been consumed cannot be used.
SMS Provider
SMS dispatch is handled via a SmsProvider contract, allowing different SMS gateway integrations to be swapped in without changing the OTP logic. The specific provider is configurable.
User Storage
The user requires a verified phone number. A phone_number field and a phone_verified_at timestamp are added to the User entity. A pending code table stores the hashed code, expiry, and consumed state per user.
Tasks
SMS OTP is a post-launch 2FA method that sends a one-time code to a verified phone number as the second factor. It implements the
TwoFactorProvidercontract.Flow
RawTokenis issuedA code that has expired or already been consumed cannot be used.
SMS Provider
SMS dispatch is handled via a
SmsProvidercontract, allowing different SMS gateway integrations to be swapped in without changing the OTP logic. The specific provider is configurable.User Storage
The user requires a verified phone number. A
phone_numberfield and aphone_verified_attimestamp are added to theUserentity. A pending code table stores the hashed code, expiry, and consumed state per user.Tasks
SmsProvidercontractSmsOtpProvidersatisfying theTwoFactorProvidercontractSmsProviderphone_numberandphone_verified_attoUser