Read from the package's own PHP files at the commit 085c59bfb829: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.
RecaptchaGatewayclassA reCAPTCHA token, checked by Google:
6 methods · 8 constants
RecaptchaGatewayFactoryclassGoogle reCAPTCHA: the widget from Google, its token checked by direct calls - siteverify for v2 and v3, the assessments API for Enterprise.
13 options · 1 method
Omnishield\Recaptcha
RecaptchaGateway class
final class RecaptchaGateway implements ChallengeInterface RecaptchaGateway.php:32
A reCAPTCHA token, checked by Google:
- checkbox, invisible, score: POST https://www.google.com/recaptcha/api/siteverify (secret, response, remoteip) - success, challenge_ts, hostname, error-codes; score and action for v3 (https://developers.google.com/recaptcha/docs/verify, /docs/v3);
- enterprise: POST https://recaptchaenterprise.googleapis.com/v1/projects/<project>/assessments?key=<api key> ({"event": {"token", "siteKey", "expectedAction", "userIpAddress"}}) - tokenProperties (valid, invalidReason, hostname, action, createTime), riskAnalysis (score, reasons) (https://docs.cloud.google.com/recaptcha/docs/create-assessment-website).
A token lasts two minutes and serves once. The page's part - when to ask Google for a token in the invisible and score modes - is a short script of this package's, printed with the widget.
const CHECKBOX = 'checkbox'const INVISIBLE = 'invisible'const SCORE = 'score'const ENTERPRISE = 'enterprise'const MODES = [self::CHECKBOX, self::INVISIBLE, self::SCORE, self::ENTERPRISE]const FIELD = 'g-recaptcha-response'const TEST_SITE_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI'const TEST_SECRET = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe'
RecaptchaGateway::__construct()
public function __construct(readonly HttpClientInterface $http, readonly string $mode, readonly string $siteKey, readonly string $secret = '', readonly ?string $projectId = null, readonly ?string $apiKey = null, readonly float $threshold = 0.5, readonly string $defaultAction = 'submit', readonly string $domain = 'www.google.com', readonly ?string $language = null, readonly array $attributes = [])RecaptchaGateway::getName()
public function getName(): stringRecaptchaGateway::getTitle()
public function getTitle(): stringRecaptchaGateway::capabilities()
public function capabilities(): CapabilitiesRecaptchaGateway::widget()
public function widget(?string $action = null): WidgetRecaptchaGateway::verify()
public function verify(Attempt $attempt): VerdictRecaptchaGatewayFactory class
final class RecaptchaGatewayFactory extends GatewayFactory RecaptchaGatewayFactory.php:36
Google reCAPTCHA: the widget from Google, its token checked by direct calls - siteverify for v2 and v3, the assessments API for Enterprise.
options: mode: checkbox # checkbox (v2), invisible (v2), score (v3), enterprise site_key: '%env(RECAPTCHA_SITE_KEY)%' # required secret: '%env(RECAPTCHA_SECRET)%' # required but for enterprise project_id: my-project # enterprise: required, the Google Cloud project api_key: '%env(RECAPTCHA_API_KEY)%' # enterprise: required, an API key of that project threshold: 0.5 # score and enterprise: under it, refused default_action: submit # score and enterprise: the action when the form names none domain: www.google.com # or www.recaptcha.net, where google.com's other cookies are not language: ~ # the widget's language (hl): fr, de theme: ~ # checkbox: light, dark size: ~ # checkbox: normal, compact badge: ~ # invisible: bottomright, bottomleft, inline attributes: } # any other attribute of the element
Google's test keys for v2 (site key 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI, secret 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe) pass every token, from testkey.google.com: with them the host is not checked. v3 and Enterprise have none.
Options
| Option | Default | |
|---|---|---|
omnishield.required_options | array_merge(['site_key'], 'enterprise' === ($c['mode'] ?? null) ? ['project_id', 'api_key'] : ['secret']) | |
mode | RecaptchaGateway::CHECKBOX | |
secret | null | |
project_id | null | |
api_key | null | |
threshold | 0.5 | |
default_action | 'submit' | |
domain | 'www.google.com' | |
language | null | |
theme | null | |
size | null | |
badge | null | |
attributes | [] |
RecaptchaGatewayFactory::__construct()
public function __construct(readonly ?HttpClientInterface $http = null)