google/cloud-recaptcha-enterprise
Official Google Cloud PHP client for reCAPTCHA Enterprise, letting Laravel and PHP apps create assessments, manage site keys, and verify tokens through the Google Cloud API.
Architecture fit
google/cloud-recaptcha-enterprise is a GAPIC-generated Google Cloud client library, not a Laravel package. It ships Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient and the Assessment / TokenProperties / RiskAnalysis message classes. There is no service provider, no config file, no facade, no Blade/validation integration — every one of those is ours to write.grecaptcha.enterprise.execute(siteKey, {action})), our Laravel backend calls createAssessment() with {siteKey, token, expectedAction, hashedAccountId?}, and reads tokenProperties.valid + riskAnalysis.score + reasons.recaptcha/api/siteverify call in reCAPTCHA v3. That matters: v3 is effectively on a deprecation path in favour of Enterprise, so adopting this library is as much a forward-compatibility decision as a fraud-scoring one.RecaptchaVerifier interface, and expose it as a custom validation rule or a middleware/FormRequest concern. That wrapper is the actual product; the SDK is a transport detail.Integration feasibility
^1.0, requires PHP 8.x and pulls google/gax, google/protobuf, guzzlehttp/guzzle, plus either grpc/grpc or the REST transport. Verify the exact PHP floor against our Laravel version before committing.GOOGLE_APPLICATION_CREDENTIALS) or Workload Identity. This is the single biggest operational difference from v3, which only needed a shared secret in .env. We now have a GCP project, an enabled API, an IAM principal (roles/recaptchaenterprise.agent), and a key-rotation story.createAssessment, annotateAssessment, createKey/getKey (or keys managed manually in console), and optionally getMetrics. Low integration risk.Technical risk
Key questions
grpc installed and permitted in prod, or do we mandate the REST transport?accountId) and password-leak verification, or is plain score+action sufficient for phase 1?Stack fit
config/recaptcha.php — project id, site key(s), credentials path, score thresholds, enabled surfaces, timeout, fail-open flag.RecaptchaServiceProvider — binds a singleton RecaptchaEnterpriseServiceClient and a RecaptchaVerifier implementation.RecaptchaVerifier interface — verify(string $token, string $action, ?string $accountId): VerificationResult. This is the seam that lets us mock in tests and swap to REST/HTTP later without touching call sites.ValidRecaptcha validation rule + a EnsureRecaptcha middleware for non-form endpoints.AnnotateAssessment job for the feedback loop.Migration path (from reCAPTCHA v3)
roles/recaptchaenterprise.agent.RecaptchaVerifier wrapper — no call sites changed yet.createAssessment and log score/action/reasons/latency for N weeks. This is the most valuable step and the one most likely to be skipped.annotateAssessment on downstream outcomes (signup completed, order paid, chargeback, account banned) — this is where Enterprise earns its keep over v3, and it requires product/risk to own the label definitions.createAssessment parameter and does not require re-integration.Compatibility
grecaptcha.enterprise) with a site key from the Enterprise key. Old v3 site keys do not work here — this is a coordinated front-end/back-end release, not a backend-only change.render/execute lifecycle all change; budget front-end time.Sequencing
getMetrics dashboards.Maintenance
google/protobuf, google/gax, and grpc are all in the tree and can conflict with other Google dependencies (BigQuery, Pub/Sub, Firebase). If we already pull google/cloud-* anywhere, resolve the whole tree together.Support
Scaling
createAssessment inside a loop over form fields.Failure modes
| Failure | Symptom | Mitigation |
|---|---|---|
| Credentials expired/misconfigured | 401/403 on all protected surfaces | Alert on auth error rate; key rotation runbook; prefer Workload Identity over static JSON |
Quota exhausted (RESOURCE_EXHAUSTED) |
Spikes during bot attacks — exactly when we need it | Per-surface quotas, circuit breaker, fail-open policy for low-risk surfaces |
| Google API outage | Timeouts across forms | Short timeout (300–500ms), circuit breaker, explicit degraded path |
| Duplicate token submission | INVALID_ARGUMENT, looks like a bot |
Idempotency at the form layer; don't retry assessments |
| Expired token (>2 min) | Silent score failures on slow forms | Front-end refresh on submit; measure token age |
| Site key mismatch / wrong project | 100% invalid | Config validation at boot, health-check endpoint |
| gRPC extension missing in one environment | Works in staging, fails in prod (or vice versa) | Pin transport explicitly, assert in CI |
Ramp-up
Bottom line for the product decision
.env variable for a cloud dependency we cannot operate.How can I help you explore Laravel packages today?