security-patterns

Implement JWT authentication, rate limiting, and Zod input validation for Cloudflare Workers.

Updated Mar 11, 2025
One-click install
npx skills add https://github.com/MohammedSaudAlsahli/dotfiles --skill security-patterns-mohammedsaudalsahli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: security-patterns
Source: https://github.com/MohammedSaudAlsahli/dotfiles/tree/main/ai/agents-skills/security-patterns
Command: npx skills add https://github.com/MohammedSaudAlsahli/dotfiles --skill security-patterns-mohammedsaudalsahli

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires better-auth, zod, cf-connecting-ip, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenge of implementing robust security patterns and practices in Cloudflare Workers applications, including authentication, rate limiting, input validation, and AI safety.

Core Features & Use Cases

  • Authentication & Authorization: Integrates Better Auth with JWT for secure user management.
  • Rate Limiting: Implements rate limiting to prevent abuse and protect against DDoS attacks.
  • Input Validation: Uses Zod for server-side input validation to ensure data integrity.
  • AI Safety: Offers guidelines and practices to mitigate AI-related risks.
  • Use Case: When developing a Cloudflare Workers API, this Skill can be used to ensure that the API is secure against common vulnerabilities and follows best practices.

Quick Start

Use the security-patterns skill to create an authenticated route that limits the number of requests per minute.

Frequently Asked Questions about security-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT authentication in Cloudflare Workers?

JWT authentication in Cloudflare Workers is implemented by integrating Better Auth, providing secure user management and authorization for server-side APIs.

What's the best way to validate input on Cloudflare Workers?

The best way to validate input on Cloudflare Workers is using Zod for server-side validation, ensuring data integrity and preventing common API vulnerabilities.

How does rate limiting work with cf-connecting-ip in Cloudflare Workers?

Rate limiting with cf-connecting-ip in Cloudflare Workers works by tracking requests per IP address, preventing API abuse and protecting against DDoS attacks.

Can I use Better Auth with Zod for input validation in my Workers API?

Yes, you can use Better Auth with Zod in your Workers API to combine secure JWT user management with strict server-side input validation for robust security.

When do I need AI safety practices in my Cloudflare Workers application?

You need AI safety practices in your Cloudflare Workers application when integrating AI features, using specific guidelines to mitigate AI-related risks and ensure secure operations.

Does this security pattern approach support server-side validation for APIs?

Yes, this security pattern approach supports server-side validation for APIs, utilizing Zod to ensure data integrity and protect against common vulnerabilities in Cloudflare Workers.