Token & Domini

Crea nuovo token

Gestione Clienti

Crea nuovo cliente

I miei clienti

Username Azioni

Report Sessioni

→
—
Totali
—
Bloccati
—
Bot
—
Sospetti
—
Umani
—
Score medio

Andamento nel tempo

Sessioni recenti

Data Verdict Score Dominio Pagina IP Segnali Motivo blocco

Gestione Utenti

Crea nuovo utente

Assegnazione Clienti a Gestori

Assegnazioni Attive

GestoreClienteAccesso TotaleAzioni

Utenti registrati

Username Email Ruolo Crea token Max domini Creato Azioni

Il mio profilo

Modifica email

Cambia password

Integrazione Node.js / NestJS

1. Includi lo script HTML

Inserisci nel <head> di ogni pagina con un form da proteggere.

<script defer
  src="/wecaptcha.js"
  data-token="LA_TUA_SITE_KEY"
  data-api=""
  data-threshold="0.4"
  data-debug="false"
></script>

2. Aggiungi data-bd-protect al form

<form action="/login" method="POST" data-bd-protect>
  <input type="email"    name="email">
  <input type="password" name="password">
  <button type="submit">Accedi</button>
</form>

3. Validazione server-side — Express

// middleware riutilizzabile
async function wecaptchaGuard(req, res, next) {
  const proof     = req.body['bd-proof']
  const siteKey   = 'LA_TUA_SITE_KEY'
  const secretKey = 'LA_TUA_SECRET_KEY'
  const apiBase   = ''
  const r = await fetch(`${apiBase}/captcha/validate?tokenId=${siteKey}&secretKey=${secretKey}&proof=${proof}`)
  const { valid } = await r.json()
  if (!valid) return res.status(403).json({ error: 'Bot detected' })
  next()
}

4. Validazione server-side — NestJS Guard

// wecaptcha.guard.ts
@Injectable()
export class WeCaptchaGuard implements CanActivate {
  async canActivate(ctx: ExecutionContext): Promise<boolean> {
    const req       = ctx.switchToHttp().getRequest()
    const proof     = req.body['bd-proof']
    const siteKey   = 'LA_TUA_SITE_KEY'
    const secretKey = 'LA_TUA_SECRET_KEY'
    const apiBase   = ''
    const res  = await fetch(`${apiBase}/captcha/validate?tokenId=${siteKey}&secretKey=${secretKey}&proof=${proof}`)
    const { valid } = await res.json()
    if (!valid) throw new ForbiddenException('Bot detected')
    return true
  }
}

API endpoints

MetodoEndpointDescrizione
POST/captcha/verifyVerifica sessione → score + sessionProof
POST/captcha/reportReport blocco client-side
GET/captcha/validateValida sessionProof lato server
GET/captcha/reportsLista report (auth richiesta)
POST/admin/tokensCrea token (auth)
GET/admin/tokensLista token (auth)
POST/auth/loginLogin → JWT
GET/auth/meProfilo utente corrente

Integrazione PHP

1. Setup

require_once 'WeCaptcha.php';

$wc = new WeCaptcha(
    '',  // apiBase
    'LA_TUA_SITE_KEY',                   // siteKey (public)
    'LA_TUA_SECRET_KEY'                  // secretKey (private)
);

2. Verifica

// Metodo 1 — verifica manuale
$result = $wc->verify($_POST['bd-proof'] ?? null);
if (!$result->valid) {
    http_response_code(403);
    exit('Bot rilevato: ' . $result->error);
}

// Metodo 2 — eccezione automatica
try {
    $wc->protect($_POST['bd-proof'] ?? null);
} catch (RuntimeException $e) {
    http_response_code(403);
    exit($e->getMessage());
}

3. Form HTML

<form method="POST" data-bd-protect>
  <input type="email" name="email" required>
  <input type="password" name="password" required>
  <button type="submit">Accedi</button>
</form>
<script defer
  src="/wecaptcha.js"
  data-token="LA_TUA_SITE_KEY"
  data-api="">
</script>

Integrazione Pimcore (Symfony Bundle)

wecaptcha-pimcore-bundle.zip
Bundle pronto per l'installazione in Pimcore 10 / 11
Scarica Bundle

Installazione

  1. Scarica il pacchetto e scompattalo nella cartella src/WecaptchaBundle
  2. Abilita il bundle nel file config/bundles.php:
    Alea\WecaptchaBundle\WecaptchaBundle::class => ['all' => true]
  3. Configura i parametri in config/packages/wecaptcha.yaml:
    parameters:
        wecaptcha.api_base:   ''
        wecaptcha.site_key:   'LA_TUA_SITE_KEY'
        wecaptcha.secret_key: 'LA_TUA_SECRET_KEY'

Inclusione script in Twig

Inietta il tag <script defer> nel layout base passandolo dal controller:

// Controller
public function layoutAction(WecaptchaService $wc): Response {
    return $this->render('layout.html.twig', [
        'wecaptcha_script' => $wc->renderScript(),
    ]);
}

{# layout.html.twig #}
{{ wecaptcha_script | raw }}

Aggiungi data-bd-protect al form da proteggere:

<form method="post" action="..." data-bd-protect> ... </form>

Validazione nel Controller

// Esempio di validazione manuale in un controller Pimcore
public function contactAction(Request $request, WecaptchaService $wecaptcha) {
    if ($request->isMethod('POST')) {
        $valid = $wecaptcha->verify($request->get('bd-proof'));
        if (!$valid) {
            throw new \Exception('Bot detected!');
        }
    }
}

Plugin WordPress

wecaptcha-for-wordpress.zip
Plugin pronto per l'installazione via WP Admin
Scarica ZIP

Installazione

  1. Clicca Scarica ZIP qui sopra
  2. WordPress Admin → Plugin → Aggiungi nuovo → Carica plugin
  3. Seleziona wecaptcha-for-wordpress.zip → Installa → Attiva
  4. Vai in Impostazioni → WeCaptcha
  5. Inserisci URL server, Site Key e Secret Key

Form protetti automaticamente

FormHook WordPressAttivabile da
LoginauthenticateImpostazioni plugin
Registrazioneregistration_errorsImpostazioni plugin
Commentipreprocess_commentImpostazioni plugin
Contact Form 7wpcf7_spamImpostazioni plugin

Uso programmatico

// Verifica manuale in qualsiasi hook
$result = wecaptcha()->verify($_POST['bd-proof'] ?? null);
if (!$result->valid) {
    wp_die(esc_html($result->error), 'Accesso negato', ['response' => 403]);
}