feat(api): implement recaptcha v3 anti-spam protection
- Add RecaptchaValidatorInterface and RecaptchaResult entity in Domain - Create RecaptchaValidationService in Application layer - Implement GoogleRecaptchaValidator for API integration - Add recaptcha-settings schema and admin FormBuilder - Integrate reCAPTCHA validation in NewsletterAjaxHandler - Integrate reCAPTCHA validation in ContactFormAjaxHandler - Update FooterRenderer and ContactFormRenderer with reCAPTCHA scripts - Configure DIContainer with RecaptchaValidationService injection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,10 @@ use ROITheme\Shared\Domain\Contracts\PostGridShortcodeRendererInterface;
|
||||
use ROITheme\Shared\Infrastructure\Query\PostGridQueryBuilder;
|
||||
use ROITheme\Shared\Infrastructure\Ui\PostGridShortcodeRenderer;
|
||||
use ROITheme\Shared\Application\UseCases\RenderPostGrid\RenderPostGridUseCase;
|
||||
// reCAPTCHA Anti-spam System
|
||||
use ROITheme\Shared\Domain\Contracts\RecaptchaValidatorInterface;
|
||||
use ROITheme\Shared\Infrastructure\Services\GoogleRecaptchaValidator;
|
||||
use ROITheme\Shared\Application\Services\RecaptchaValidationService;
|
||||
|
||||
/**
|
||||
* DIContainer - Contenedor de Inyección de Dependencias
|
||||
@@ -542,4 +546,35 @@ final class DIContainer
|
||||
}
|
||||
return $this->instances['renderPostGridUseCase'];
|
||||
}
|
||||
|
||||
// ===============================
|
||||
// reCAPTCHA Anti-spam System
|
||||
// ===============================
|
||||
|
||||
/**
|
||||
* Obtiene el validador de reCAPTCHA (comunicacion con API de Google)
|
||||
*/
|
||||
public function getRecaptchaValidator(): RecaptchaValidatorInterface
|
||||
{
|
||||
if (!isset($this->instances['recaptchaValidator'])) {
|
||||
$this->instances['recaptchaValidator'] = new GoogleRecaptchaValidator();
|
||||
}
|
||||
return $this->instances['recaptchaValidator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtiene el servicio de validacion reCAPTCHA
|
||||
*
|
||||
* Orquesta la validacion usando configuracion de BD
|
||||
*/
|
||||
public function getRecaptchaValidationService(): RecaptchaValidationService
|
||||
{
|
||||
if (!isset($this->instances['recaptchaValidationService'])) {
|
||||
$this->instances['recaptchaValidationService'] = new RecaptchaValidationService(
|
||||
$this->getRecaptchaValidator(),
|
||||
$this->getComponentSettingsRepository()
|
||||
);
|
||||
}
|
||||
return $this->instances['recaptchaValidationService'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user