gpt4 book ai didi

asp.net - Google reCAPTCHA 响应成功 : false, 无错误代码

转载 作者:行者123 更新时间:2023-12-01 11:20:51 32 4
gpt4 key购买 nike

更新:谷歌有 recently updated their error message带有额外的错误代码可能性:“超时或重复”。

这个新的错误代码似乎涵盖了我们之前提到的 99% 的神秘
案件。

我们仍然想知道为什么我们会收到那么多超时或重复的验证请求。肯定地确定这一点可能是不可能的,但现在我只是希望其他人也经历过类似的事情。

免责声明:我交叉发布此 to Google Groups ,很抱歉为经常访问这两个站点的人发送垃圾邮件。

我目前正在处理一个页面,作为 ASP.Net MVC 应用程序的一部分,其中包含一个使用 reCAPTCHA 验证的表单。该页面目前有很多日常用户。
在我对 reCAPTCHA 响应的服务器端验证**中,一段时间以来,我已经看到 reCAPTCHA 响应的成功属性设置为 false,但伴随着空错误代码数组的情况。
大多数请求都通过了验证,但有些请求仍然表现出这种模式。

所以在网上做了一些研究之后,我探索了我能想到的两种可能的情况:

  • 验证已超时,不再有效。
  • 用户已经使用响应值进行了验证,因此他们第二次被拒绝。

  • 在收集了一段时间的数据后,我发现所有“成功:错误,错误代码:[]”的情况要么验证很旧(从 5 分钟到 10 天(!)),要么已经重用响应值的情况,或者有时是两者的组合。
    即使在实现客户端防止双击我的提交表单按钮之后,很多重复提交似乎仍然通过服务器端 Google reCAPTCHA 验证逻辑。

    我的数据告诉我,在所有请求 (1760) 中,有 1.6% (28) 失败,并且上述场景中至少有一个是正确的(“超时”或“双重提交”)。
    同时,在错误代码数组不为空的情况下,没有一个 1760 请求失败。

    我只是很难想象一个实际用例,其中发出 ChallengeTimeStamp,然后在 10 天后尝试验证,服务器端。

    我的问题是:

    在所有谷歌 reCAPTCHA 服务器端验证尝试中,不可忽略的百分比要么很旧要么是双重提交的情况可能是什么原因?

    **通过“服务器端验证”我的意思是逻辑看起来像这样:
        public bool IsVerifiedUser(string captchaResponse, string endUserIp)
    {
    string apiUrl = ConfigurationManager.AppSettings["Google_Captcha_API"];
    string secret = ConfigurationManager.AppSettings["Google_Captcha_SecretKey"];
    using (var client = new HttpClient())
    {
    var parameters = new Dictionary<string, string>
    {
    { "secret", secret },
    { "response", captchaResponse },
    { "remoteip", endUserIp },
    };
    var content = new FormUrlEncodedContent(parameters);
    var response = client.PostAsync(apiUrl, content).Result;
    var responseContent = response.Content.ReadAsStringAsync().Result;
    GoogleCaptchaResponse googleCaptchaResponse = JsonConvert.DeserializeObject<GoogleCaptchaResponse>(responseContent);

    if (googleCaptchaResponse.Success)
    {
    _dal.LogGoogleRecaptchaResponse(endUserIp, captchaResponse);
    return true;
    }
    else
    {
    //Actual code ommitted
    //Try to determine the cause of failure
    //Look at googleCaptchaResponse.ErrorCodes array (this has been empty in all of the 28 cases of "success: false")
    //Measure time between googleCaptchaResponse.ChallengeTimeStamp (which is UTC) and DateTime.UtcNow
    //Check reCAPTCHAresponse against local database of previously used reCAPTCHAresponses to detect cases of double submission
    return false;
    }
    }
    }

    在此先感谢任何有线索并可能对这个主题有所了解的人。

    最佳答案

    如果您的验证码经过两次验证,您将遇到超时或重复问题。
    以追加模式将日志保存在文件中,并检查您是否两次验证 Captcha。
    这是一个例子

    $verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret='.$secret.'&response='.$_POST['g-recaptcha-response'])

    file_put_contents( "logfile", $verifyResponse, FILE_APPEND );

    现在阅读上面创建的日志文件的内容并检查验证码是否经过两次验证

    关于asp.net - Google reCAPTCHA 响应成功 : false, 无错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43678256/

    32 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com