Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom score thresholds for reCAPTCHA #3

Merged
merged 3 commits into from
Mar 17, 2021

Conversation

kodumbeats
Copy link
Contributor

With reCAPTCHA v3, each the server-side check has the following response model:

{
  "success": true|false,      // whether this request was a valid reCAPTCHA token for your site
  "score": number             // the score for this request (0.0 - 1.0)
  "action": string            // the action name for this request (important to verify)
  "challenge_ts": timestamp,  // timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ)
  "hostname": string,         // the hostname of the site where the reCAPTCHA was solved
  "error-codes": [...]        // optional
}

Since v3 implements a scoring system of 0.0 < x < 1.0, the success field no longer represents the bot check, but only if the provided token is valid.

This PR allows the check() method to accept a $score float parameter and will return the success bool as expected. The Google-suggested default is x=0.5.

@kodumbeats kodumbeats marked this pull request as draft March 17, 2021 18:55
@kodumbeats kodumbeats marked this pull request as ready for review March 17, 2021 19:41
@eldadfux eldadfux merged commit 2b8cc40 into utopia-php:master Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants