Skip to content

Commit c6364e8

Browse files
author
Muhammad Ali
committed
[Agents] Add authentication section to Agents docs
Adds a dedicated Authentication section with focused pages for each approach: - Overview (authentication/index.mdx) with decision table and best practices. - Token and middleware auth (authentication/token-and-middleware.mdx) covering static token validation, JWT verification, passing tokens from clients, per-instance authorization, and Hono middleware. - Workers OAuth Provider (authentication/oauth-provider.mdx) covering OAuth 2.1 authorization server setup, third-party IdP integration (GitHub example), and token scoping and revocation. - Full-stack auth with Better Auth (authentication/better-auth.mdx) with a full tutorial for user management, D1 setup, JWT issuance, and client integration. This replaces the stale PR #28654. Incorporates review feedback: - Removed links to the cloudflare/agents auth-agent example from better-auth.mdx; the example was rewritten as a lightweight JWT demo and no longer demonstrates Better Auth. - Corrected the 'Lazy initialization' note in better-auth.mdx. Environment bindings are available at module scope via 'import { env } from "cloudflare:workers"'. The real reason for the lazy singleton is that betterAuth()'s init() does async I/O (telemetry filesystem detection via dynamic import("fs/promises")) that only resolves inside a request context. - Added a 'Complete example' link to token-and-middleware.mdx pointing at the auth-agent example, since that page describes the JWT pattern the example now demonstrates. - Updated the auth-agent description in index.mdx to reflect that it demonstrates JWT auth, not Better Auth.
1 parent 9c753ff commit c6364e8

4 files changed

Lines changed: 1134 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)