Skip to content

Allow custom score thresholds for reCAPTCHA - #3

Merged
eldadfux merged 3 commits into
utopia-php:masterfrom
kodumbeats:feat-score-recaptcha-v3
Mar 17, 2021
Merged

eldadfux merged 3 commits into
utopia-php:masterfrom
kodumbeats:feat-score-recaptcha-v3

Conversation

@kodumbeats

Copy link
Copy Markdown
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