[identity] TOTP Service - enhance recipient and channel handling#1108
Merged
Conversation
Refactored TOTP recipient logic to support phone number, email, or user ID as identifiers. Enhanced SendAsync and builder pattern to accept new parameters (email, template, data, classification) and support multiple delivery channels (Email, PushNotification, generic). Added recipient resolution and channel validation. Improved XML docs and performed minor cleanup.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the TotpServiceSecurityToken flow to support multiple recipient identifiers (phone number, email, or user ID) and expands message/channel configuration to support Email and PushNotification delivery, aligning the security-token TOTP service with broader multi-channel delivery needs in the Identity features.
Changes:
- Extended
TotpServiceSecurityToken.SendAsyncto accept phone/email/userId plus email template, data, and classification, including recipient resolution and channel validation. - Updated the security-token parameters builder to support selecting receiver by phone/email/user and selecting additional delivery channels.
- Adjusted the TOTP modifier logic in
TotpServiceBaseto be recipient-based rather than phone-number-only.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Indice.Features.Identity.Server/Totp/TotpHandlers.cs | Minor cleanup (removed unused using). |
| src/Indice.Features.Identity.Core/Totp/TotpServiceSecurityTokenParametersBuilder.cs | Builder updates to support email/user recipients, more channels, and extra optional parameters. |
| src/Indice.Features.Identity.Core/Totp/TotpServiceSecurityToken.cs | Core refactor to resolve recipients (incl. userId), validate channels, and send via multiple delivery mechanisms. |
| src/Indice.Common/Services/TotpServiceBase.cs | Updated modifier generation to work with generalized recipient identifiers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Refactored ValidateChannel for consistent formatting. Fixed a typo in the TOTP verification method (recipiet → recipient). Added logic to resolve and check the User object by userId at the start of the main method.
Refactored all usages of "emailTemplate" to "template" in TotpServiceSecurityToken, builder classes, and TotpServiceSecurityTokenParameters to generalize template usage beyond email. Updated method parameters, builder methods, and XML docs for consistency. The TOTP cache key now includes the token value, which may impact rate limiting.
…thub.com/indice-co/Indice.Platform into feature/identity/totp-service-extensions
Refactored `ValidateChannel` in `TotpServiceSecurityToken` to use an `out` error parameter and return a `bool`, updating all usages. Enhanced `TotpServiceTests` with `.AddEmailServiceNoop()` and a comprehensive set of new tests covering service creation, TOTP code delivery, error handling, rate limiting, developer mode, user resolution, and factory constructor validation.
Removed commented-out code and explanatory comments from TOTP tests for clarity. Updated rate-limiting test to assert IsRateLimited explicitly. Removed redundant comment in TotpServiceFactory null input test.
… IDisposable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactored TOTP recipient logic to support phone number, email, or user ID as identifiers. Enhanced SendAsync and builder pattern to accept new parameters (email, template, data, classification) and support multiple delivery channels (Email, PushNotification, generic). Added recipient resolution and channel validation. Improved XML docs and performed minor cleanup.