You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Similar to Email authentication it should be possible to create an account using SMS authentication.
Describe the solution you'd like
SMS authentication added to the serverpod_auth_module complete with server and flutter code.
Documentation for the new provider in the Serverpod docs.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
PR to start the work from here: #1362
Might be able to incorporate and close this issue: #729
Two storage strategies: Hash (HMAC-SHA256) and Crypto (AES-256-GCM)
Rate limiting for verification codes
Full documentation (English + Chinese)
Compatible with Serverpod 3.2.3+
Architecture:
Follows the new IDP (Identity Provider) pattern from Serverpod 3.x
7 modular packages with clear separation of concerns
Already battle-tested in production
I'd be happy to discuss contributing this to the official auth module,
or keeping it as a community package. What's the team's preference? @SandPod@vlidholt
I'd be happy to discuss contributing this to the official auth module, or keeping it as a community package. What's the team's preference?
@Metaildust I will be very nice if you want to implement the SMS support on the new auth module! We already have several utilities that might facilitate the work a lot (for hashing, creating secret challenges and rate limiting). If you want to work on it, I can assign you to the issue and give you more details on how it could be implemented reusing these utils.
Configurable rate limiting and verification code expiry
Database schema following email auth patterns
Questions for Discussion
Design alignment: Does this architecture align with Serverpod's expectations, or are there changes needed?
Provider abstraction: Currently using a callback interface for SMS sending - is this the preferred approach, or should we have a dedicated SMS provider abstraction?
Phone storage strategies: I've split hash-only (serverpod_auth_sms_hash) and encrypted (serverpod_auth_sms_crypto) into separate packages, allowing developers to choose based on their privacy requirements. Should these remain separate, or be consolidated?
I'm ready to adapt the implementation based on feedback and work through the PR process. Please let me know how to proceed.
base endpoint + configurable callbacks (normalizeHandle, buildNonce, sendLoginVerificationCode, resolveAuthUserId)
Step 2: SMS as an extension (OTP-only)
Once Step 1 is merged, I’ll submit a follow-up PR that refactors the SMS provider to build on passwordless and keeps the phone-specific pieces:
PhoneIdHashStore / PhoneIdCryptoStore
phone normalization + binding flow
widgets on Flutter side
Phone hashing strategy
The phone lookup hash is deterministic and uses HMAC-SHA256 (not Argon2), because it needs to support indexing / account lookup.
Out of scope
phone+password flow: to be proposed after Step 1 + Step 2
2FA/MFA: separate issue
@marcelomendoncasoares If this looks good, is there anything you’d like adjusted in Step 1 before review/merge? Otherwise I’ll start preparing the Step 2 refactor in parallel.
@Metaildust Nice to know that you're reusing all of the internals and that you have followed the email implementation! This will make the integration a lot simpler, then. For the design of the feature, I'll make a proposition to build it in two steps:
A generic providers/passwordless provider that exposes the workflow for any passwordless login alternative.
An SMS extension to the passwordless provider that adds the phone-specific features and widgets.
This will both simplify the review process and make the core of the feature reusable for other providers in the future. It is the same pattern we have done on the other providers that resulted in the utilities that will be reused here. If you agree with this direction, I'll suggest splitting each step in a PR, so that we can ensure that each is properly tested.
For the tests of the passwordless implementation, I suggest taking inspiration on the email tests - which will be very natural since you have already followed the email implementation.
Regarding your other questions from the first message:
Provider abstraction: Using the callback is just fine and makes it very easy to integrate with providers.
Phone storage strategies: Nice that you have followed all best practices! Since there are no complex dependencies, you can put them both in the existing IDP packages (server and flutter, as needed). We try to minimize the number of dependencies, since Dart's tree shaking already handles removing unnecessary code from the compiled binaries. The only reason for splitting is when some IDP depends on platform-specific implementations, since native code is not tree-shaken and can break users code. But this also happens only on the Flutter side, as with Firebase.
Update: I’ve opened PR #4699 for Step 1 (generic passwordless/OTP provider). I’ll keep the initial PRs strictly passwordless-first (generic passwordless + SMS OTP extension), and move phone+password to a follow-up PR once the first two are merged.
2FA/MFA will be handled in a separate issue/PR after this.
For an upstream PR, would you prefer: A) keep the initial PRs strictly passwordless-first (generic passwordless provider + SMS OTP), and move phone+password to a follow-up PR (optionally behind a feature flag), or B) add configuration flags so users can explicitly enable/disable each flow (and we can choose conservative defaults)?
I would go with option A, to first have the passwordless in and then add the password option as a follow-up. We can then evaluate if the best strategy is to create a new one extending the passwordless SMS or expose the password as configuration flag.
Related: do you consider SMS 2FA (second factor after a primary login) in scope for this work, or should that be handled separately?
We should discuss it separately. On a general thought, to add 2FA (or MFA), we need to:
Expose a way for developers to configure a list of additional IDPs that should be invoked after a first successful authentication. This needs to account for all possible strategies:
Enforce a sequence of fixed IDPs that must be used - like SMS as 2FA.
Require N from any IDPs that a user has registered - excepting the one that was used to authenticate.
Require N from an intersection of IDPs between a fixed list and the ones a user has registered.
Add a hook to the additional IDPs - which might require allowing to flag an AuthSuccess as incomplete and bearing extra information to know which IDP to invoke next on the app.
Enhance the SignInWidget to parse the extra information on the app to invoke the required IDPs for the next required authentication.
Besides this, we need to also allow specifying which providers can be used as login or MFA or both.
If you want to work on this, I can create an issue with these details and assign it to you! But I'd suggest leaving it for after the first PRs just to avoid opening too many fronts at once.
Activity
SandPod commentedon May 22, 2025
Draft implementation here: #1362
Metaildust commentedon Feb 1, 2026
provided solution in #4667
Hi, I've implemented an SMS authentication module for Serverpod that's already published on pub.dev:
📦 serverpod_auth_sms - https://pub.dev/packages/serverpod_auth_sms
Features:
Architecture:
I'd be happy to discuss contributing this to the official auth module,
or keeping it as a community package. What's the team's preference?
@SandPod @vlidholt
marcelomendoncasoares commentedon Feb 5, 2026
@Metaildust I will be very nice if you want to implement the SMS support on the new auth module! We already have several utilities that might facilitate the work a lot (for hashing, creating secret challenges and rate limiting). If you want to work on it, I can assign you to the issue and give you more details on how it could be implemented reusing these utils.
Metaildust commentedon Feb 5, 2026
Hi @marcelomendoncasoares and Serverpod team,
I've built a community SMS authentication module that's currently published on pub.dev:
Current Implementation
The package already uses official Serverpod utilities:
Argon2HashUtilfor password/verification code hashingSecretChallengeUtilfor the verification flow (create → verify → complete)DatabaseRateLimitedRequestAttemptUtilfor rate limitingArchitecture (mirrors
serverpod_auth_email):serverpod_auth_sms- Main integration packageserverpod_auth_sms_core/_client- Core logicserverpod_auth_sms_hash/_client- Hash-based phone storage (HMAC-SHA256 for lookup)serverpod_auth_sms_crypto/_client- Crypto-based phone storage (AES-GCM encrypted + hash)Features:
Questions for Discussion
serverpod_auth_sms_hash) and encrypted (serverpod_auth_sms_crypto) into separate packages, allowing developers to choose based on their privacy requirements. Should these remain separate, or be consolidated?I'm ready to adapt the implementation based on feedback and work through the PR process. Please let me know how to proceed.
Metaildust commentedon Feb 5, 2026
To clarify the current implementation status (and align with the proposed two-step approach):
Step 1: Generic passwordless provider (OTP-only)
I’ve implemented the generic
providers/passwordlessprovider and opened PR #4699:SecretChallengeUtil)PasswordlessLoginRequest(with migration)PasswordlessLoginException(+ Reason enum)normalizeHandle,buildNonce,sendLoginVerificationCode,resolveAuthUserId)Step 2: SMS as an extension (OTP-only)
Once Step 1 is merged, I’ll submit a follow-up PR that refactors the SMS provider to build on passwordless and keeps the phone-specific pieces:
PhoneIdHashStore/PhoneIdCryptoStorePhone hashing strategy
The phone lookup hash is deterministic and uses HMAC-SHA256 (not Argon2), because it needs to support indexing / account lookup.
Out of scope
@marcelomendoncasoares If this looks good, is there anything you’d like adjusted in Step 1 before review/merge? Otherwise I’ll start preparing the Step 2 refactor in parallel.
Metaildust commentedon Feb 5, 2026
Hi @marcelomendoncasoares,
I'm ready to start the PR work. Before proceeding, I'd like to confirm the expected code structure.
Currently in the repo, email auth is a provider directory under:
My existing implementation uses separate packages, but I'm leaning toward option 1 for the PR:
Proposed approach: Restructure into
providers/sms/(like email)This keeps consistency with the email pattern and simplifies the user experience - one integration, configuration-based flexibility.
If this approach works, I'll start the PR. Please let me know if you have a different preference!
feat(auth): add SMS authentication provider
marcelomendoncasoares commentedon Feb 5, 2026
@Metaildust Nice to know that you're reusing all of the internals and that you have followed the email implementation! This will make the integration a lot simpler, then. For the design of the feature, I'll make a proposition to build it in two steps:
providers/passwordlessprovider that exposes the workflow for any passwordless login alternative.This will both simplify the review process and make the core of the feature reusable for other providers in the future. It is the same pattern we have done on the other providers that resulted in the utilities that will be reused here. If you agree with this direction, I'll suggest splitting each step in a PR, so that we can ensure that each is properly tested.
For the tests of the passwordless implementation, I suggest taking inspiration on the email tests - which will be very natural since you have already followed the email implementation.
Regarding your other questions from the first message:
What do you think?
Metaildust commentedon Feb 5, 2026
Thanks! I agree with option A.
Update: I’ve opened PR #4699 for Step 1 (generic passwordless/OTP provider). I’ll keep the initial PRs strictly passwordless-first (generic passwordless + SMS OTP extension), and move phone+password to a follow-up PR once the first two are merged.
2FA/MFA will be handled in a separate issue/PR after this.
marcelomendoncasoares commentedon Feb 5, 2026
I would go with option A, to first have the passwordless in and then add the password option as a follow-up. We can then evaluate if the best strategy is to create a new one extending the passwordless SMS or expose the password as configuration flag.
We should discuss it separately. On a general thought, to add 2FA (or MFA), we need to:
AuthSuccessas incomplete and bearing extra information to know which IDP to invoke next on the app.SignInWidgetto parse the extra information on the app to invoke the required IDPs for the next required authentication.Besides this, we need to also allow specifying which providers can be used as login or MFA or both.
If you want to work on this, I can create an issue with these details and assign it to you! But I'd suggest leaving it for after the first PRs just to avoid opening too many fronts at once.
Metaildust commentedon Feb 5, 2026
@marcelomendoncasoares I’ve opened PR #4699 for Step 1 (generic
providers/passwordless, OTP-only) and the checks are now passing.Once Step 1 is merged, I’ll follow up with Step 2 (SMS extension, OTP-only) refactor.
Any feedback on the Step 1 PR would be appreciated.