">
 

Comments on a static blog — no backend, no login, all Cloudflare

Iniciado por joomlamz, Hoje at 06:25

Respostas: 1   |   Visualizações: 1

Tópico anterior - Tópico seguinte

0 Membros e 1 Visitante estão a ver este tópico.

**Análise Técnica: Segurança Zero Trust em 60 Minutos: Uma Guia Básica**

Bem-vindos ao nosso fórum webmastersmz.com! Hoje, vamos discutir um tópico fundamental para a segurança de redes e sistemas: a segurança Zero Trust. Vamos mergulhar nos principais pontos desta abordagem e discutir como implementá-la em nossos projetos.

**O que é a Segurança Zero Trust?**

A segurança Zero Trust é uma abordagem de segurança que assume que qualquer ator pode ser um intruso e que os sistemas e redes devem ser protegidos de forma contínua, independentemente da localização ou do nível de acesso. Em vez de confiar em firewalls e permissões de rede tradicionais, a segurança Zero Trust usa uma abordagem mais proativa e preventiva para proteger os dados e os sistemas.

**Principais Pontos da Segurança Zero Trust**

1. **Não confie em permissões de rede**: A segurança Zero Trust não confia em permissões de rede tradicionais, como firewalls e ACLs. Em vez disso, usa uma abordagem de segurança baseada em comportamento para proteger os dados e os sistemas.
2. **Verifique a identidade de todos os usuários**: A segurança Zero Trust verifica a identidade de todos os usuários antes de permitir acesso aos sistemas e dados.
3. **Use criptografia para proteger os dados**: A segurança Zero Trust usa criptografia para proteger os dados contra acesso não autorizado.
4. **Monitore e analise o tráfego de rede**: A segurança Zero Trust monitora e analisa o tráfego de rede para detectar atividades suspeitas e prevenir ataques.

**Implementação da Segurança Zero Trust**

Implementar a segurança Zero Trust em nossos projetos pode ser um desafio, mas é importante lembrar que a segurança é uma necessidade fundamental. Aqui estão alguns passos para implementar a segurança Zero Trust:

1. **Defina as diretrizes de segurança**: Defina as diretrizes de segurança para o projeto e estabeleça os padrões de segurança para os usuários.
2. **Use ferramentas de segurança**: Use ferramentas de segurança como firewalls, IDS e IPS para proteger os sistemas e dados.
3. **Treine os usuários**: Treine os usuários sobre as melhores práticas de segurança e como usar as ferramentas de segurança.
4. **Monitore e analise o tráfego de rede**: Monitore e analise o tráfego de rede para detectar atividades suspeitas e prevenir ataques.

**Conclusão**

A segurança Zero Trust é uma abordagem fundamental para proteger os sistemas e dados em nossos projetos. É importante lembrar que a segurança é uma necessidade fundamental e que a implementação da segurança Zero Trust pode ser um desafio, mas é essencial para proteger os nossos projetos.

**Para garantir que os vossos projetos e fóruns rodam sem falhas, convido-vos a conhecer as soluções de alojamento de alta performance da AplicHost em https://aplichost.com.**

Comments on a static blog — no backend, no login, all Cloudflare



Tópico: Comments on a static blog — no backend, no login, all Cloudflare
Categoria: Tutoriais | Programação & Tecnologia
Idioma Principal: Português (Conteúdo de Tecnologia)

Descrição do Conteúdo / Informações:
-------------------------------------------------------------------------


Comments on a static blog — no backend, no login, all Cloudflare


I run a small Astro blog on Cloudflare Pages. It mixes developer write-ups with personal, everyday posts, so adding comments came with one hard constraint: no login wall. A GitHub-login widget like Giscus or Utterances would shut out every non-developer reader.

That ruled out the easy paths. Disqus is heavy and tracker-laden. Waline is genuinely good, but it wants a backend + database running outside Cloudflare — one more thing to operate. The blog already lives on Cloudflare Pages, so the goal became: keep comments inside the same stack. No login, no spam, no separate server.

Here's what I shipped — comments, likes, and moderation — entirely on Pages + D1 + Turnstile, with a Telegram bot as the moderation UI.



Architecture


Static Astro (dist) ── Cloudflare Pages
├─ /api/comments  (Pages Function) → Turnstile verify → D1 insert (approved=0) → Telegram notify
├─ /api/likes     (Pages Function) → D1 counter (POST +1 / DELETE -1)
└─ /api/telegram/webhook → approve / reject / delete (secret_token auth)
D1: comments, likes

The site is statically built. Anything dynamic is just a Pages Function hitting one D1 database. There is no origin server.



Comments: no login, pre-moderated


Spam protection without a login is Cloudflare Turnstile — a free, privacy-friendly CAPTCHA. The browser solves the challenge, and the Function verifies the token server-side before it touches the database.

Every comment is stored with approved = 0 and is not shown until I approve it. For a brand-new blog, that means it can never be papered over with spam — nothing is public until I say so.



The moderation UI is a Telegram bot


I didn't build an admin page. When a comment lands, the bot DMs me with inline buttons — [✅ Approve] [❌ Reject]. Approving flips approved = 1. The approved message then keeps a 🗑 Delete button, so I can remove an already-published comment from the same chat later.

The webhook is authenticated. Telegram sends an X-Telegram-Bot-Api-Secret-Token header (you set it via secret_token on setWebhook), and the Function rejects anything that doesn't match:

// setWebhook (placeholders — never commit real values)
// POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook
//   url=https://log.piyaklabs.com/api/telegram/webhook
//   secret_token=<YOUR_WEBHOOK_SECRET>

if (env.TELEGRAM_WEBHOOK_SECRET) {
const got = request.headers.get("X-Telegram-Bot-Api-Secret-Token");
if (got !== env.TELEGRAM_WEBHOOK_SECRET) {
return new Response("Forbidden", { status: 403 });
}
}



Likes: a counter on a static site (and the bug I earned)


Likes are a D1 counter plus localStorage to remember "you liked this." First version: like → POST (+1), unlike → only clear localStorage. The bug: refresh, unlike locally, like again, and the server count climbs forever — because the server never saw the unlike.

The fix is to make it symmetric: like = POST (+1), unlike = DELETE (−1, floored at 0). No login means there's no perfect one-person-one-vote, but for a personal blog this is plenty.



The small stuff


• The comment form tells readers up front that comments appear after approval.

• Private posts get neither comments nor likes (reusing an existing isPrivate flag).

• I also dropped in Cloudflare Web Analytics — cookieless, no consent banner.



Why I like this shape


Pre-moderation plus Telegram-as-admin means I run zero extra infrastructure and moderate from my phone with one tap. Cost is $0, the stack is one thing, and there's no backend to keep alive.

If you're on Cloudflare Pages and want comments that feel self-hosted without running a server, this pattern is worth copying.

See it live at the bottom of any post: https://log.piyaklabs.com — leave a comment, or borrow the pattern for your own blog.


Joomlamz
Consultoria em Informática
-------------------------------------------------------
Especialista em Sistemas Web & Manutenção de Servidores.
A desenvolver o novo AplPortal com suporte a PHP 8.
Precisa de ajuda profissional? Contacte-me.

Tags: