Networks and Cloudflare Edge: Portelcore Contact Firewall
Serverless edge firewall architecture in Cloudflare to mitigate spam and secure the contact form.
In this document, we detail the security architecture that we have deployed at the edge (edge network) of our network using Cloudflare Workers and associated services to protect and optimize Portelcore's contact and appointment scheduling form.
Edge Security Architecture
Sección titulada «Arquitectura de Seguridad en el Borde»The exposed surface of the contact form is one of the most common vectors for application denial-of-service attacks (Layer 7 DoS) and mass spam emails. To mitigate this risk, we implemented a three-layer validation before processing any request on our backend servers.
sequenceDiagram actor Usuario as Cliente / Bot participant CF as 🛡️ Cloudflare Workers participant TS as 🤖 Cloudstile / Turnstile participant DB as 💾 Worker KV Cache participant API as ⚙️ Portelcore API / Cal.com
Usuario->>CF: Enviar solicitud de contacto / cita CF->>TS: Validar token de desafío Turnstile alt Desafío Fallido TS-->>CF: Token inválido / Bot detectado CF-->>Usuario: Bloqueo de solicitud (403 Forbidden) else Desafío Exitoso TS-->>CF: Token válido (Humano) CF->>DB: Verificar límites de rate-limiting (IP/Email) alt Límite Excedido DB-->>CF: IP sospechosa o rate limit alcanzado CF-->>Usuario: Error de límite (429 Too Many Requests) else Límite Correcto CF->>API: Canalizar solicitud (Envío OTP / Reserva Cal.com) API-->>Usuario: Confirmación y Token OTP enviado end endSystem Components
Sección titulada «Componentes del Sistema»1. Cloudflare Workers (Serverless Filter)
Sección titulada «1. Cloudflare Workers (Filtro Serverless)»We have configured a Worker on the contact form's API route to intercept and pre-process HTTP POST requests. This offloads the computational load from the local data center servers and blocks malicious traffic directly on Cloudflare's global distribution network.
- Advantages:
- Ultra-low latency (distributed execution at edge locations).
- No need to maintain dedicated proxy servers for Layer 7 filtering.
2. Integration with Cloudflare Turnstile
Sección titulada «2. Integración con Cloudflare Turnstile»Instead of conventional interactive CAPTCHAs that hinder the user experience, we use Turnstile to verify client validity invisibly or non-intrusively through telemetry and browser behavior challenges.
- Server Validation: The worker validates the client key against the Turnstile API:
const response = await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {method: 'POST',body: JSON.stringify({ secret: SECRET_KEY, response: token }),headers: { 'Content-Type': 'application/json' }});
3. Appointment Authentication via OTP
Sección titulada «3. Autenticación de Citas mediante OTP»For technical appointment requests that require identity confirmation, the Worker implements a One-Time Password (OTP) flow sent to the requester's email.
- The OTP state is temporarily stored in Cloudflare KV with a short Time-To-Live (TTL of 5 minutes).
- This ensures that the email addresses entered in the form are valid and that they are interacted with by the legitimate user.
4. Integration with Cal.com and Orchestration API
Sección titulada «4. Integración con Cal.com y API de Orquestación»Once the user's identity is validated and security challenges are passed, the Worker securely redirects booking requests to the internal Cal.com API or to the Portelcore technical support queue, preventing automated fake bookings on our calendars.

