new UnsetArrayValue(), // Issuing a challenge calculates the KDF once, so the public endpoint must be limited 'rateLimiter' => [ 'class' => IpRateLimiter::class, 'only' => ['altcha-challenge'], 'keyPrefix' => 'captcha:altcha:challenge:ratelimit', 'limits' => [ 60 => 30, 3600 => 300, ], ], ]); } /** * @return array */ public function verbs(): array { return [ 'altcha-challenge' => ['GET'], ]; } public function actionAltchaChallenge(CaptchaRegistry $captchaRegistry): array { try { /** @var \api\components\Captcha\Providers\Altcha $altcha */ $altcha = $captchaRegistry->getProvider(Altcha::NAME); } catch (\Throwable $e) { throw new NotFoundHttpException(previous: $e); } // Every response is unique, so neither nginx nor the browser must cache it Yii::$app->response->headers->set('Cache-Control', 'no-store'); return $altcha->createChallenge(); } }