cloudflare-zero-trust-access
БесплатноБез исполняемых скриптовНе проверенCloudflare Zero Trust Access authentication for Cloudflare Workers applications. Covers hono- cloudflare-access middleware setup, manual Access JWT validation…
Об этом скилле
Cloudflare Zero Trust Access Skill
Integrate Cloudflare Zero Trust Access authentication with Cloudflare Workers applications using proven patterns and templates.
Overview
This skill provides complete integration patterns for Cloudflare Access, enabling application-level authentication for Workers without managing your own auth infrastructure.
What is Cloudflare Access? Cloudflare Access is Zero Trust authentication that sits in front of your application, validating users before they reach your Worker. After authentication, Access issues JWT tokens that your Worker validates.
Key Benefits:
- No auth infrastructure to maintain
- Integrates with identity providers (Azure AD, Google, Okta, GitHub)
- Service tokens for machine-to-machine auth
- Built-in MFA and session management
- Comprehensive audit logs
When to Use This Skill
Trigger this skill when tasks involve:
- Authentication: Protecting Worker routes, securing admin dashboards, API authentication
- Access Control: Role-based access (RBAC), group-based permissions, geographic restrictions
- Service Auth: Backend services calling Worker APIs, CI/CD pipelines, cron jobs
- Multi-Tenant: SaaS apps with organization-level authentication
- CORS + Auth: Single-page applications calling protected APIs
Keywords to Trigger: cloudflare access, zero trust, access authentication, JWT validation, service tokens, cloudflare auth, hono access, workers authentication, protect worker routes, admin authentication
Integration Patterns
Pattern 1: Hono Middleware (Recommended)
Use @hono/cloudflare-access for one-line Access integration.
When to Use:
- Building with Hono framework
- Need quick, production-ready setup
- Want automatic JWT validation and key caching
Template: templates/hono-basic-setup.ts
Setup:
import { Hono } from 'hono'
import { cloudflareAccess } from '@hono/cloudflare-access'
const app = new Hono<{ Bindings: Env }>()
// Public routes
app.get('/', (c) => c.text('Public page'))
// Protected routes
app.use(
'/admin/*',
cloudflareAccess({
domain: (c) => c.env.ACCESS_TEAM_DOMAIN,
})
)
app.get('/admin/dashboard', (c) => {
const { email } = c.get('accessPayload')
return c.text(`Welcome, ${email}!`)
})
Configuration (wrangler.jsonc):
{
"vars": {
"ACCESS_TEAM_DOMAIN": "your-team.cloudflareaccess.com",
"ACCESS_AUD": "your-app-aud-tag"
}
}
Benefits:
- ✅ Automatic JWT validation
- ✅ Public key caching (1-hour TTL)
- ✅ Type-safe with TypeScript
- ✅ Production-tested and maintained
Pattern 2: Manual JWT Validation
Use Web Crypto API for custom validation logic.
When to Use:
- Not using Hono framework
- Need custom validation beyond standard checks
- Want full control over JWT verification
Template: templates/jwt-validation-manual.ts
Key Functions:
// Validate JWT signature and claims
async function validateAccessJWT(
token: string,
env: Env
): Promise<AccessJWTPayload> {
// 1. Decode header to get kid
// 2. Fetch public keys (with caching)
// 3. Verify signature using Web Crypto API
// 4. Validate aud, exp, iss
// 5. Return payload
}
Complexity: ~100 lines Dependencies: None (uses Web Crypto API)
Pattern 3: Service Token Authentication
Use service tokens for machine-to-machine auth.
When to Use:
- Backend services calling your Worker API
- CI/CD pipelines
- Automated scripts and cron jobs
- No interactive login needed
Template: templates/service-token-auth.ts
Client Side (sending request):
const response = await fetch('https://api.example.com/data', {
headers: {
'CF-Access-Client-Id': env.SERVICE_TOKEN_ID,
'CF-Access-Client-Secret': env.SERVICE_TOKEN_SECRET,
},
})
Server Side (Worker):
// Same validation as user JWTs - middleware handles both
app.use('/api/*', cloudflareAccess({
domain: (c) => c.env.ACCESS_TEAM_DOMAIN
}))
app.get('/api/data', (c) => {
const payload = c.get('accessPayload')
// Detect service token vs user
const isService = !payload.email && payload.common_name
return c.json({
authenticated_by: isService ? 'service-token' : 'user',
identifier: payload.email || payload.common_name,
})
})
Setup Guide: references/service-tokens-guide.md
Pattern 4: CORS + Access
Handle cross-origin requests with Access authentication.
When to Use:
- SPA (React/Vue/Angular) calling protected API
- Frontend and API on different domains
- Cross-origin authenticated requests
Template: templates/cors-access.ts
CRITICAL: CORS middleware MUST come before Access middleware!
import { cors } from 'hono/cors'
import { cloudflareAccess } from '@hono/cloudflare-access'
// ✅ CORRECT ORDER
app.use('*', cors({
origin: 'https://app.example.com',
credentials: true, // Allow cookies
}))
app.use('/api/*', cl
Установить cloudflare-zero-trust-access в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashВложенные файлы
FAQ
Что делает скилл cloudflare-zero-trust-access?
Cloudflare Zero Trust Access authentication for Cloudflare Workers applications. Covers hono- cloudflare-access middleware setup, manual Access JWT validation with public key caching, service tokens for machine-to-machine auth, CORS handling in front of Access, identity providers (Azure AD, Google Workspace, Okta, GitHub), role-based access control, geographic restrictions, multi-tenant configurations, and Access policy setup. Prevents eight common errors including blocked CORS preflight requests, key cache race conditions, missing JWT headers, and dev/prod team mismatches. Use when protecting Worker routes or admin dashboards with Access, validating Access JWT claims, authenticating backend services or CI/CD jobs to a Worker API, or debugging blocked preflight requests, a missing Access JWT header, or team mismatch errors.
Как установить скилл cloudflare-zero-trust-access?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cloudflare-zero-trust-access запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic