Limit repeated access code requests via caching
Introduced a mechanism to limit repeated access code requests within a configurable time period using `IMemoryCache` and a new `RepeatRequestBlockingPeriod` configuration in `SendAccessCodeParams`. Key changes: - Added `SendAccessCodeParams` configuration to `appsettings.json`. - Updated DI in `DependencyInjection.cs` to include `SendAccessCodeParams`. - Enhanced `SendAccessCodeCommand` with `MultipleRequestsAllowed`. - Updated `SendAccessCodeCommandHandler` to handle caching logic: - Added `IsAccessCodeRequestsDisabled` and `DisableAccessCodeRequests`. - Modified `AuthController` to support `autoGenerated` query parameter. - Improved error handling and documentation. These changes ensure better control over access code requests and prevent abuse by limiting repeated requests within a configurable time window.
This commit is contained in:
@@ -12,6 +12,7 @@ using EnvelopeGenerator.Application.DocReceiverElements.Commands;
|
||||
using EnvelopeGenerator.Application.DocReceiverElements.Behaviors;
|
||||
using EnvelopeGenerator.Application.Common.Behaviors;
|
||||
using FluentValidation;
|
||||
using EnvelopeGenerator.Application.EnvelopeReceivers.Commands;
|
||||
|
||||
namespace EnvelopeGenerator.Application;
|
||||
|
||||
@@ -53,6 +54,7 @@ public static class DependencyInjection
|
||||
services.Configure<AuthenticatorParams>(config.GetSection(nameof(AuthenticatorParams)));
|
||||
services.Configure<TotpSmsParams>(config.GetSection(nameof(TotpSmsParams)));
|
||||
services.Configure<ESignParams>(config.GetSection(nameof(ESignParams)));
|
||||
services.Configure<SendAccessCodeParams>(config.GetSection(nameof(SendAccessCodeParams)));
|
||||
|
||||
services.AddHttpClientService<GtxMessagingParams>(config.GetSection(nameof(GtxMessagingParams)));
|
||||
services.TryAddScoped<ISmsSender, GTXSmsSender>(); // Changed: Singleton → Scoped
|
||||
|
||||
Reference in New Issue
Block a user