Drop-in plugin
app.register(authdogPlugin, { publicKey }) decorates every request with an idiomatic request.authdog context: token, user, and isAuthenticated.
- One registration
- Idiomatic request context
Fastify
A tiny, high-performance plugin that validates Authdog sessions on every request and gives you an idiomatic request.authdog context plus a requireAuth guard.
Register the plugin
// server.ts
import { authdogPlugin } from "@authdog/fastify"
await app.register(authdogPlugin, {
publicKey: process.env.AUTHDOG_PK!,
})
Gate routes with a preHandler
// routes.ts
app.get("/me", {
preHandler: app.authdog.requireAuth,
}, async (request) => request.authdog!.user)
A plugin, not a framework
A drop-in plugin, a requireAuth guard, and a typed request context, with no assumptions about your stack.
app.register(authdogPlugin, { publicKey }) decorates every request with an idiomatic request.authdog context: token, user, and isAuthenticated.
Gate any route with app.authdog.requireAuth as a preHandler. This is the real enforcement point, since request.authdog itself is informational.
The public key and its identity host are validated once at registration, and tokens are only trusted after the identity host confirms them.
The plugin reads the authdog-session cookie or a Bearer header on its own, so @fastify/cookie isn't required to get started.
A tiny plugin with an option to skip the per-request userinfo call when you validate tokens elsewhere.
request.authdog and app.authdog are typed via module augmentation, so the session context and guard come with full autocomplete.
Add @authdog/fastify and your environment's public key.
await app.register(authdogPlugin, { publicKey }).
Add requireAuth as a preHandler where you need it.
Install the SDK, register the plugin, and gate your routes with requireAuth today. Free to start, with secure defaults built in.