Google 的 Recaptcha V3 - 我应该跟踪分数,还是只要 "success" 为真就足够了?
Google's Recaptcha V3 - should I track the score, or suffice with the "success" being true?
背景:我的网站非常简单,包含一个带有链接列表的主页(由第 3 方服务提供)- 每个链接都会弹出一个带有提交按钮的文件上传输入。在那个弹出窗口中,我嵌入了 Recaptcha 脚本,并在文件提交时验证了令牌。由于这种多弹出设置,我选择 V3 来实现与验证机制的零用户交互。
现在,出现了一个问题——我应该如何解释 Google 来自 google 的回复。
Google V3 文档说:
reCAPTCHA learns by seeing real traffic on your site. For this reason,
scores in a staging environment or soon after implementing may differ
from production. As reCAPTCHA v3 doesn't ever interrupt the user flow,
you can first run reCAPTCHA without taking action and then decide on
thresholds by looking at your traffic in the admin console. By
default, you can use a threshold of 0.5.
我很清楚,从这个描述中,score
是最重要的 - 0.0 最有可能是机器人,1.0 最有可能是人类。所以在我的代码中,我检查 success == true
和 score >= 0.5
但是 - none 我在网上找到的用于服务器端验证的 V3 示例请注意分数。这是其中的 3 个。这三个都只检查请求是否成功:
https://dzone.com/articles/adding-google-recaptcha-v3-to-your-laravel-app
最后,我的问题是——这是对 V3 机制的误解,还是我遗漏了什么?
谢谢。
是的,您绝对应该在 Google 的验证响应中检查 "score" 的值。
这三个例子非常缺乏细节,实际上非常混乱。
"success" 只是意味着您发送了一个格式正确的请求,其中包含正确的令牌和密码。
听起来你已经在检查 "score" 的值了,这很好,但我只是想为发现这个问题但仍然有点困惑的人澄清一下。
补充@BrettM 的回答...
这取决于验证的处理方式。
使用reCAPTCHA PHP client library:
查看代码行 ReCaptcha::verify() line180-182
- 设置阈值时:
$recaptcha = new Recaptcha($secret);
$response = $recaptcha
->setExpectedHostname($hostname)
->setExpectedAction($action)
->setScoreThreshold(.5)
->verify($token, $ip);
当未达到阈值时,$response->isSuccess()
将 return false
。
$response->getErrors()
将包含 E_SCORE_THRESHOLD_NOT_MET
- 不设置阈值:
$response->isSuccess()
会returntrue
,除非有错误。
$response->getScore()
现在应该检查。
不使用 reCAPTCHA PHP 客户端库:
$response['success'] 和 $response['score'] 都应该检查。
背景:我的网站非常简单,包含一个带有链接列表的主页(由第 3 方服务提供)- 每个链接都会弹出一个带有提交按钮的文件上传输入。在那个弹出窗口中,我嵌入了 Recaptcha 脚本,并在文件提交时验证了令牌。由于这种多弹出设置,我选择 V3 来实现与验证机制的零用户交互。
现在,出现了一个问题——我应该如何解释 Google 来自 google 的回复。
Google V3 文档说:
reCAPTCHA learns by seeing real traffic on your site. For this reason, scores in a staging environment or soon after implementing may differ from production. As reCAPTCHA v3 doesn't ever interrupt the user flow, you can first run reCAPTCHA without taking action and then decide on thresholds by looking at your traffic in the admin console. By default, you can use a threshold of 0.5.
我很清楚,从这个描述中,score
是最重要的 - 0.0 最有可能是机器人,1.0 最有可能是人类。所以在我的代码中,我检查 success == true
和 score >= 0.5
但是 - none 我在网上找到的用于服务器端验证的 V3 示例请注意分数。这是其中的 3 个。这三个都只检查请求是否成功:
https://dzone.com/articles/adding-google-recaptcha-v3-to-your-laravel-app
最后,我的问题是——这是对 V3 机制的误解,还是我遗漏了什么?
谢谢。
是的,您绝对应该在 Google 的验证响应中检查 "score" 的值。
这三个例子非常缺乏细节,实际上非常混乱。
"success" 只是意味着您发送了一个格式正确的请求,其中包含正确的令牌和密码。
听起来你已经在检查 "score" 的值了,这很好,但我只是想为发现这个问题但仍然有点困惑的人澄清一下。
补充@BrettM 的回答...
这取决于验证的处理方式。
使用reCAPTCHA PHP client library:
查看代码行 ReCaptcha::verify() line180-182
- 设置阈值时:
当未达到阈值时,$recaptcha = new Recaptcha($secret); $response = $recaptcha ->setExpectedHostname($hostname) ->setExpectedAction($action) ->setScoreThreshold(.5) ->verify($token, $ip);
$response->isSuccess()
将 returnfalse
。
$response->getErrors()
将包含E_SCORE_THRESHOLD_NOT_MET
- 不设置阈值:
$response->isSuccess()
会returntrue
,除非有错误。
$response->getScore()
现在应该检查。
不使用 reCAPTCHA PHP 客户端库:
$response['success'] 和 $response['score'] 都应该检查。