Implement ALTCHA captcha service with challenge generation and solution verification
- Added AltchaService class for managing ALTCHA captcha challenges and solutions. - Created CaptchaController to handle API requests for generating challenges. - Introduced CaptchaGuard for validating captcha solutions on public endpoints. - Developed unit tests for AltchaService to ensure challenge creation and solution verification functionality. - Implemented integration tests for the Captcha API endpoint and captcha bypass behavior when disabled. - Added documentation for the Captcha API in the corresponding markdown file.
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Clinic\Entity\Clinic;
|
||||
use App\Clinic\Repository\ClinicRepository;
|
||||
use App\Doctor\Entity\Doctor;
|
||||
use App\Doctor\Repository\DoctorRepository;
|
||||
use App\Shared\Captcha\CaptchaGuard;
|
||||
use App\Shared\Constant\ErrorCodes;
|
||||
use App\Shared\Controller\BaseController;
|
||||
use App\Sms\Service\SmsService;
|
||||
@@ -35,11 +36,14 @@ class PreRegistrationController extends BaseController
|
||||
private readonly SmsService $sms,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly string $appUrl,
|
||||
private readonly CaptchaGuard $captcha,
|
||||
) {}
|
||||
|
||||
#[Route('/api/v1/pre-registration', methods: ['POST'])]
|
||||
public function submit(Request $request): JsonResponse
|
||||
{
|
||||
$this->captcha->assertValid($request);
|
||||
|
||||
$data = json_decode($request->getContent(), true) ?? [];
|
||||
$type = trim($data['type'] ?? '');
|
||||
$name = trim($data['name'] ?? '');
|
||||
|
||||
Reference in New Issue
Block a user