Replace reCAPTCHA service to tencent captcha on backend side

Problem to solve

Replace reCAPTCHA service to Tencent Captcha on backend side.

Overview of reCAPTCHA usage

Gitlab is using reCAPTCHA to protect websites from spams, which has been integrated within HTML forms and APIs.

For HTML requests, the reCAPTCHA uses recaptcha_tags to load frontend partials in views with recaptcha_enabled? as a checking flag and uses params['g-recaptcha-response'] for backend verification.

For APIs, the needs_captcha_response will be added in HTTP response header to let clients know that reCAPTCHA response is needed and it uses X-GitLab-Captcha-Response in HTTP request headers for backend.

Proposal

  1. Add a flag variable to determine when reCAPTCHA will be replaced by Tencent Captcha.
  2. Override the recaptcha_tags method.
  3. Override the recaptcha_verify_via_api_call and point it to Tencent Cloud.

How to

  1. To enable this feature, #478 (closed) frontend required.
  2. This feature can be enabled by execute Feature.enable :tencent_captcha
Martin Tan 编辑于