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
| Gestore | Cliente | Accesso Totale | Azioni |
|---|
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 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
| 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
'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
Installazione
- Scarica il pacchetto e scompattalo nella cartella
src/WecaptchaBundle - Abilita il bundle nel file
config/bundles.php:Alea\WecaptchaBundle\WecaptchaBundle::class => ['all' => true]
- 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
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, Site Key e Secret Key
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_spam | 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]);
}