Token & Domini
Crea nuovo token
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
Utenti registrati
| Username | 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 src="/wecaptcha.js" data-token="IL_TUO_TOKEN_ID" 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 tokenId = 'IL_TUO_TOKEN_ID'
const apiBase = ''
const r = await fetch(`${apiBase}/captcha/validate?tokenId=${tokenId}&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 tokenId = 'IL_TUO_TOKEN_ID'
const apiBase = ''
const res = await fetch(`${apiBase}/captcha/validate?tokenId=${tokenId}&proof=${proof}`)
const { valid } = await res.json()
if (!valid) throw new ForbiddenException('Bot detected')
return true
}
}
API endpoints
| Metodo | Endpoint | Descrizione |
|---|---|---|
| POST | /captcha/verify | Verifica sessione → score + sessionProof |
| POST | /captcha/report | Report blocco client-side |
| GET | /captcha/validate | Valida sessionProof lato server |
| GET | /captcha/reports | Lista report (auth richiesta) |
| POST | /admin/tokens | Crea token (auth) |
| GET | /admin/tokens | Lista token (auth) |
| POST | /auth/login | Login → JWT |
| GET | /auth/me | Profilo utente corrente |
Integrazione PHP
1. Setup
require_once 'WeCaptcha.php';
$wc = new WeCaptcha(
apiBase: '',
tokenId: 'IL_TUO_TOKEN_ID'
);
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 src="/wecaptcha.js" data-token="IL_TUO_TOKEN_ID" data-api=""> </script>
Plugin WordPress
wecaptcha-for-wordpress.zip
Plugin pronto per l'installazione via WP Admin
Installazione
- Clicca Scarica ZIP qui sopra
- WordPress Admin → Plugin → Aggiungi nuovo → Carica plugin
- Seleziona
wecaptcha-for-wordpress.zip→ Installa → Attiva - Vai in Impostazioni → WeCaptcha
- Inserisci URL server e Token ID
Form protetti automaticamente
| Form | Hook WordPress | Attivabile da |
|---|---|---|
| Login | authenticate | Impostazioni plugin |
| Registrazione | registration_errors | Impostazioni plugin |
| Commenti | preprocess_comment | Impostazioni plugin |
| Contact Form 7 | wpcf7_before_send_mail | Impostazioni 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]);
}