Auth for AI agents and humans. First-class agent identity, MCP OAuth 2.1, delegation, audit. TypeScript, edge-native, MIT.
See the code
Open-source auth for AI agents and humans.
Agent identity, delegation, MCP OAuth 2.1 server, DPoP, passkeys, device flow. A self-hostable Better Auth alternative for TypeScript.
Website · Quickstart · Docs · Examples · Discussions · GLINR Discord
Most auth libraries stop at human sign-in. Once an AI agent needs its own identity, scoped permissions, delegation from a user, and an audit trail, you end up bolting a second system on. theAuth puts agents and humans in one library: sign-in methods, an OAuth 2.1 authorization server for MCP, and agent tokens with permissions you can check and audit.
It runs on Node, Bun, Deno and Cloudflare Workers with three runtime dependencies (drizzle-orm, jose, zod). MIT licensed. No hosted service required.
Runs as pasted with SQLite. Needs Node 20 or newer.
npm install @glinr/theauth
import { createTheAuth, users } from "@glinr/theauth";
const auth = await createTheAuth({
database: { provider: "sqlite", url: ":memory:" },
agents: { enabled: true }, // creates the agent and audit tables
});
// Agents need an owner row in theauth_users (human auth creates these for you).
auth.db.insert(users).values({
id: "user-123", email: "owner@example.com", name: "Owner",
createdAt: new Date(), updatedAt: new Date(),
}).run();
const agent = await auth.agent.create({
ownerId: "user-123",
name: "github-reader",
type: "autonomous",
permissions: [{ resource: "mcp:github:*", actions: ["read"] }],
});
console.log(agent.token); // "kv_..." shown once
const { allowed } = await auth.authorize(agent.id, { action: "read", resource: "mcp:github:repos" });
console.log(allowed); // true
Agent tokens start with kv_. The prefix predates the rename from Kavach and stays so issued tokens keep working (RENAME-MAP.md).
To mount it over HTTP, pick an adapter such as @glinr/theauth-hono or @glinr/theauth-nextjs (framework snippets below). To add email and password, install @glinr/theauth-email. Full walkthrough: docs.theauth.dev/quickstart. Or scaffold an app: npm create @glinr/theauth-app.
| Area | What you get | Docs |
|---|---|---|
| Agent identity | kv_ bearer tokens, wildcard permissions, delegation chains with depth limits, budget policies, denial-based trust score, CIBA-style approvals, audit trail per action | Agents |
| MCP OAuth 2.1 server | Authorization code with PKCE S256, dynamic client registration, resource indicators, metadata (RFC 7591, 8707, 8414, 9728) | MCP |
| DPoP | Sender-constrained tokens for MCP resource servers | DPoP |
| Token vault | Encrypted third-party OAuth tokens for agents, refresh with a shared lock, key rotation | Token vault |
| Human sign-in | Email and password (HIBP check), magic link, email OTP, phone OTP, passkeys, TOTP, anonymous, Google One Tap, SIWE, device flow, username, captcha | Auth |
| Providers and presets | 17 first-class OAuth providers, a generic OIDC factory, and ready-made presets for more | Providers |
| Enterprise | Organizations with RBAC, SAML 2.0 and OIDC SSO, SCIM, admin controls, API keys, GDPR export and delete, compliance evidence export (not a certification) | Docs |
| CLI | theauth doctor checks your setup for common mistakes (--json for CI) | CLI tools |
The token policy, RFC 9396 rich authorization requests and ID-JAG pieces live in the Go SDK, not here. See theauth-go.
17 providers: Apple, Atlassian, Discord, Dropbox, Figma, GitHub, GitLab, Google, LinkedIn, Microsoft, Notion, Reddit, Slack, Spotify, Twitch, Twitter/X, Zoom.
Hono, Next.js, SvelteKit, Nuxt, Express, Fastify, Astro, NestJS, SolidStart, TanStack Start, plus clients for React, Vue, Svelte, Expo and Electron. Databases: SQLite, PostgreSQL, MySQL, Cloudflare D1, and Prisma through @glinr/theauth-prisma.
npm install @glinr/theauth @glinr/theauth-nextjs
// app/api/theauth/[...theauth]/route.ts
import { createTheAuth } from "@glinr/theauth";
import { theAuthNextjs } from "@glinr/theauth-nextjs";
const auth = await createTheAuth({
database: { provider: "postgres", url: process.env.DATABASE_URL! },
});
// `authenticate` resolves the caller from the request. See the adapter docs.
export const { GET, POST, PATCH, DELETE, OPTIONS } = theAuthNextjs(auth, { authenticate });
The adapter serves agent, authorization, delegation and audit routes under /api/theauth. Human sign-in is wired separately: see the docs for the methods you enable. Working example: examples/nextjs-app.
npm install @glinr/theauth @glinr/theauth-hono
import { Hono } from "hono";
import { createTheAuth } from "@glinr/theauth";
import { theAuthHono } from "@glinr/theauth-hono";
const auth = await createTheAuth({
database: { provider: "postgres", url: process.env.DATABASE_URL! },
});
const app = new Hono();
app.route("/api/theauth", theAuthHono(auth, { authenticate }));
export default app;
Examples: hono-server, cloudflare-workers.
Every adapter has the same shape. Per-framework docs: docs.theauth.dev/adapters.
Checked against each vendor's public docs on 2026-10-07. Vendors change fast, so verify against their docs. Write-ups with sources: theauth.dev/compare.
| Capability | Auth0 | Clerk | Better Auth | theAuth |
|---|---|---|---|---|
| Source license | Proprietary | Proprietary | MIT | MIT |
| Self-hostable | Managed private cloud only | No | Yes | Yes |
| OAuth 2.1 server for MCP | Yes | Yes | Yes | Yes |
| Agent identity as its own model | Add-on: Token Vault, CIBA | Not found in docs | Plugin, not yet stable | Yes, core |
| Enterprise SSO | Yes | Yes | Plugin | SAML 2.0, OIDC, SCIM |
Where theAuth is the weaker choice: Better Auth has a larger community, more tutorials and a bigger plugin catalog. Auth0 and Clerk are managed products with hosted UIs and support contracts, which we do not match. Pick theAuth when agents are first-class users of your system and you want to run the whole thing yourself. Migration guides: migrate-from-auth0, migrate-from-better-auth-agent-plugin.
All packages live in this monorepo and publish under @glinr/.
| Group | Packages |
|---|---|
| Core | theauth, theauth-email, theauth-plugin-discovery, theauth-plugin-telemetry |
| Clients and UI | theauth-client, theauth-react, theauth-vue, theauth-svelte, theauth-expo, theauth-electron, theauth-ui, theauth-ui-headless, theauth-dashboard |
| Framework adapters | theauth-hono, theauth-nextjs, theauth-nextjs-auth, theauth-sveltekit, theauth-nuxt, theauth-express, theauth-fastify, theauth-astro, theauth-nestjs, theauth-solidstart, theauth-tanstack |
| Database | theauth-prisma |
| Tooling | create-theauth-app, theauth-cli, theauth-gateway, theauth-test-utils |
| Other languages | Go (pkg.go.dev), Python (source), Terraform provider (source) |
nextjs-app, nextjs-demo, hono-server, cloudflare-workers, mcp-server, scim-okta, basic-agent, migrate-from-auth0, migrate-from-better-auth-agent-plugin.
#theauth forum channel in the GLINR Discord.See CONTRIBUTING.md. Issues labeled good first issue are a good start. By contributing you agree to the Code of Conduct.
Report vulnerabilities privately to support@glinr.com or through the GitHub advisory form. Do not open a public issue. Details in SECURITY.md.
theAuth is built in the open by GLINCKER, a GLINR STUDIOS company. Founder: thegdsks. Sibling projects: LevelRail, theSVG, GLINUI.
Auth for AI agents and humans. First-class agent identity, MCP OAuth 2.1, delegation, audit. TypeScript, edge-native, MIT.
See the code
Open-source auth for AI agents and humans.
Agent identity, delegation, MCP OAuth 2.1 server, DPoP, passkeys, device flow. A self-hostable Better Auth alternative for TypeScript.
Website · Quickstart · Docs · Examples · Discussions · GLINR Discord
Most auth libraries stop at human sign-in. Once an AI agent needs its own identity, scoped permissions, delegation from a user, and an audit trail, you end up bolting a second system on. theAuth puts agents and humans in one library: sign-in methods, an OAuth 2.1 authorization server for MCP, and agent tokens with permissions you can check and audit.
It runs on Node, Bun, Deno and Cloudflare Workers with three runtime dependencies (drizzle-orm, jose, zod). MIT licensed. No hosted service required.
Runs as pasted with SQLite. Needs Node 20 or newer.
npm install @glinr/theauth
import { createTheAuth, users } from "@glinr/theauth";
const auth = await createTheAuth({
database: { provider: "sqlite", url: ":memory:" },
agents: { enabled: true }, // creates the agent and audit tables
});
// Agents need an owner row in theauth_users (human auth creates these for you).
auth.db.insert(users).values({
id: "user-123", email: "owner@example.com", name: "Owner",
createdAt: new Date(), updatedAt: new Date(),
}).run();
const agent = await auth.agent.create({
ownerId: "user-123",
name: "github-reader",
type: "autonomous",
permissions: [{ resource: "mcp:github:*", actions: ["read"] }],
});
console.log(agent.token); // "kv_..." shown once
const { allowed } = await auth.authorize(agent.id, { action: "read", resource: "mcp:github:repos" });
console.log(allowed); // true
Agent tokens start with kv_. The prefix predates the rename from Kavach and stays so issued tokens keep working (RENAME-MAP.md).
To mount it over HTTP, pick an adapter such as @glinr/theauth-hono or @glinr/theauth-nextjs (framework snippets below). To add email and password, install @glinr/theauth-email. Full walkthrough: docs.theauth.dev/quickstart. Or scaffold an app: npm create @glinr/theauth-app.
| Area | What you get | Docs |
|---|---|---|
| Agent identity | kv_ bearer tokens, wildcard permissions, delegation chains with depth limits, budget policies, denial-based trust score, CIBA-style approvals, audit trail per action | Agents |
| MCP OAuth 2.1 server | Authorization code with PKCE S256, dynamic client registration, resource indicators, metadata (RFC 7591, 8707, 8414, 9728) | MCP |
| DPoP | Sender-constrained tokens for MCP resource servers | DPoP |
| Token vault | Encrypted third-party OAuth tokens for agents, refresh with a shared lock, key rotation | Token vault |
| Human sign-in | Email and password (HIBP check), magic link, email OTP, phone OTP, passkeys, TOTP, anonymous, Google One Tap, SIWE, device flow, username, captcha | Auth |
| Providers and presets | 17 first-class OAuth providers, a generic OIDC factory, and ready-made presets for more | Providers |
| Enterprise | Organizations with RBAC, SAML 2.0 and OIDC SSO, SCIM, admin controls, API keys, GDPR export and delete, compliance evidence export (not a certification) | Docs |
| CLI | theauth doctor checks your setup for common mistakes (--json for CI) | CLI tools |
The token policy, RFC 9396 rich authorization requests and ID-JAG pieces live in the Go SDK, not here. See theauth-go.
17 providers: Apple, Atlassian, Discord, Dropbox, Figma, GitHub, GitLab, Google, LinkedIn, Microsoft, Notion, Reddit, Slack, Spotify, Twitch, Twitter/X, Zoom.
Hono, Next.js, SvelteKit, Nuxt, Express, Fastify, Astro, NestJS, SolidStart, TanStack Start, plus clients for React, Vue, Svelte, Expo and Electron. Databases: SQLite, PostgreSQL, MySQL, Cloudflare D1, and Prisma through @glinr/theauth-prisma.
npm install @glinr/theauth @glinr/theauth-nextjs
// app/api/theauth/[...theauth]/route.ts
import { createTheAuth } from "@glinr/theauth";
import { theAuthNextjs } from "@glinr/theauth-nextjs";
const auth = await createTheAuth({
database: { provider: "postgres", url: process.env.DATABASE_URL! },
});
// `authenticate` resolves the caller from the request. See the adapter docs.
export const { GET, POST, PATCH, DELETE, OPTIONS } = theAuthNextjs(auth, { authenticate });
The adapter serves agent, authorization, delegation and audit routes under /api/theauth. Human sign-in is wired separately: see the docs for the methods you enable. Working example: examples/nextjs-app.
npm install @glinr/theauth @glinr/theauth-hono
import { Hono } from "hono";
import { createTheAuth } from "@glinr/theauth";
import { theAuthHono } from "@glinr/theauth-hono";
const auth = await createTheAuth({
database: { provider: "postgres", url: process.env.DATABASE_URL! },
});
const app = new Hono();
app.route("/api/theauth", theAuthHono(auth, { authenticate }));
export default app;
Examples: hono-server, cloudflare-workers.
Every adapter has the same shape. Per-framework docs: docs.theauth.dev/adapters.
Checked against each vendor's public docs on 2026-10-07. Vendors change fast, so verify against their docs. Write-ups with sources: theauth.dev/compare.
| Capability | Auth0 | Clerk | Better Auth | theAuth |
|---|---|---|---|---|
| Source license | Proprietary | Proprietary | MIT | MIT |
| Self-hostable | Managed private cloud only | No | Yes | Yes |
| OAuth 2.1 server for MCP | Yes | Yes | Yes | Yes |
| Agent identity as its own model | Add-on: Token Vault, CIBA | Not found in docs | Plugin, not yet stable | Yes, core |
| Enterprise SSO | Yes | Yes | Plugin | SAML 2.0, OIDC, SCIM |
Where theAuth is the weaker choice: Better Auth has a larger community, more tutorials and a bigger plugin catalog. Auth0 and Clerk are managed products with hosted UIs and support contracts, which we do not match. Pick theAuth when agents are first-class users of your system and you want to run the whole thing yourself. Migration guides: migrate-from-auth0, migrate-from-better-auth-agent-plugin.
All packages live in this monorepo and publish under @glinr/.
| Group | Packages |
|---|---|
| Core | theauth, theauth-email, theauth-plugin-discovery, theauth-plugin-telemetry |
| Clients and UI | theauth-client, theauth-react, theauth-vue, theauth-svelte, theauth-expo, theauth-electron, theauth-ui, theauth-ui-headless, theauth-dashboard |
| Framework adapters | theauth-hono, theauth-nextjs, theauth-nextjs-auth, theauth-sveltekit, theauth-nuxt, theauth-express, theauth-fastify, theauth-astro, theauth-nestjs, theauth-solidstart, theauth-tanstack |
| Database | theauth-prisma |
| Tooling | create-theauth-app, theauth-cli, theauth-gateway, theauth-test-utils |
| Other languages | Go (pkg.go.dev), Python (source), Terraform provider (source) |
nextjs-app, nextjs-demo, hono-server, cloudflare-workers, mcp-server, scim-okta, basic-agent, migrate-from-auth0, migrate-from-better-auth-agent-plugin.
#theauth forum channel in the GLINR Discord.See CONTRIBUTING.md. Issues labeled good first issue are a good start. By contributing you agree to the Code of Conduct.
Report vulnerabilities privately to support@glinr.com or through the GitHub advisory form. Do not open a public issue. Details in SECURITY.md.
theAuth is built in the open by GLINCKER, a GLINR STUDIOS company. Founder: thegdsks. Sibling projects: LevelRail, theSVG, GLINUI.