jackspace/claudeskillz/cloudflare-zero-trust-access
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install jackspace/claudeskillz/cloudflare-zero-trust-accessSKILL.md
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:
Configuration (wrangler.jsonc):
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:
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):
Server Side (Worker):
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!
Why: OPTIONS preflight requests don't include auth headers. If Access runs first, it blocks them with 401.
Frontend:
Pattern 5: Multi-Tenant
Different Access configurations per tenant/organization.
When to Use:
- SaaS with organization-level authentication
- Each customer has separate Access team
- White-label applications
Template: templates/multi-tenant.ts
Architecture:
- Tenant config stored in D1 or KV
- Dynamic middleware based on tenant ID
- Tenant ID from subdomain, path, or header
Example:
Common Errors Prevented
This skill prevents 8 documented errors. Full details: references/common-errors.md
Error #1: CORS Preflight Blocked (45 min saved)
Problem: OPTIONS requests return 401, breaking CORS
Solution: CORS middleware BEFORE Access middleware
Error #2: Missing JWT Header (30 min saved)
Problem: Request not going through Access, no JWT header
Solution: Access Worker through Access URL, not direct *.workers.dev
Error #3: Invalid Team Name (15 min saved)
Problem: Hardcoded or wrong team name causes "Invalid issuer"
Solution: Use environment variables
Error #4: Key Cache Race (20 min saved)
Problem: First request fails, subsequent work
Solution: Use @hono/cloudflare-access (handles caching automatically)
Error #5: Service Token Headers (10 min saved)
Problem: Wrong header names, token doesn't work
Solution: Use exact header names:
Error #6: Token Expiration (10 min saved)
Problem: Users suddenly get 401 after 1 hour
Solution: Handle gracefully, redirect to login
Error #7: Multiple Policies (30 min saved)
Problem: Overlapping Access applications cause conflicts
Solution: Use most specific paths, avoid overlaps
Error #8: Dev/Prod Mismatch (15 min saved)
Problem: Code works in dev, fails in prod
Solution: Environment-specific configs
Total Time Saved: ~2.5 hours per implementation
Templates
Core Templates
- `hono-basic-setup.ts` - Standard Hono + Access integration
- Public and protected routes
- User info access
- Error handling
- `jwt-validation-manual.ts` - Manual JWT verification
- Web Crypto API usage
- Key caching
- Full validation logic
- `service-token-auth.ts` - Service token patterns
- Client and server examples
- Service vs user detection
- Best practices
- `cors-access.ts` - CORS + Access integration
- Correct middleware ordering
- Frontend examples (fetch, axios)
- Troubleshooting guide
- `multi-tenant.ts` - Multi-tenant architecture
- Subdomain, path, header strategies
- D1 tenant config
- Dynamic middleware
Configuration Templates
- `wrangler.jsonc` - Complete Wrangler configuration
- Environment variables
- Bindings (D1, KV, R2)
- Dev/staging/production environments
- `.env.example` - Environment variable template
- Required: ACCESS_TEAM_DOMAIN, ACCESS_AUD
- Optional: Service tokens, CORS config
- Setup instructions
- `types.ts` - TypeScript definitions
- AccessJWTPayload interface
- ServiceTokenJWTPayload interface
- Type guards and helpers
Reference Documentation
Comprehensive guides in references/:
- `common-errors.md` (~800 words)
- All 8 errors with solutions
- Error → Symptom → Cause → Solution → Prevention
- Source links and time savings
- `jwt-payload-structure.md` (~1,200 words)
- Complete JWT field reference
- User vs service token differences
- Type definitions and examples
- `service-tokens-guide.md` (~1,100 words)
- Creating service tokens
- Adding to policies
- Use cases (CI/CD, microservices, cron)
- Rotation best practices
- `access-policy-setup.md` (~1,400 words)
- Dashboard configuration steps
- Policy examples
- Identity provider setup
- Testing and troubleshooting
Helper Scripts
Located in scripts/:
- `test-access-jwt.sh` - JWT testing tool
- Decodes JWT header and payload
- Fetches public keys
- Validates signature and claims
- Usage:
./test-access-jwt.sh <jwt-token>
- `create-service-token.sh` - Service token setup guide
- Interactive setup instructions
- Code examples (curl, Node.js, Python, GitHub Actions)
- Best practices checklist
- Usage:
./create-service-token.sh [token-name]
Quick Start
1. Install Package
2. Configure Access
Dashboard:
- Go to Zero Trust > Access > Applications
- Create application for your Worker domain
- Create policy (e.g., "Emails ending in @company.com")
- Copy Application Audience (AUD) tag
wrangler.jsonc:
3. Add to Worker
Use templates/hono-basic-setup.ts as starting point:
4. Deploy and Test
Access: https://your-worker.example.com/admin/dashboard
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cloudflare-zero-trust-access/SKILL.md
Popularity
- Repository stars
- 12
- Repository forks
- 4
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 3 Apr 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jackspace/claudeskillz/cloudflare-zero-trust-access)