Skip to content

feat: agent auth batch for 2.0 - #272

Merged
thegdsks merged 66 commits into
mainfrom
release/agent-dx-2026-10-17
Oct 18, 2026
Merged

thegdsks merged 66 commits into
mainfrom
release/agent-dx-2026-10-17

Conversation

@thegdsks

Copy link
Copy Markdown
Member

Summary

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor (no behavior change)
  • Docs / examples only
  • Chore (deps, CI, tooling)

Related issues

Test plan

Which commands did you run to verify this change?

pnpm --filter @glinr/<package> test
pnpm typecheck
pnpm lint
  • Unit tests pass locally
  • New behavior has test coverage
  • Manual verification steps (describe below if needed)

Public API impact

  • No public API change
  • Additive change (new exports, new options)
  • Breaking change (removed/renamed exports, changed option types)

If breaking: describe the migration path.

Database migration

  • No migration needed
  • Migration file added in packages/core/migrations/

Framework adapter impact

  • No adapter changes
  • Adapter(s) affected:

If adapters are affected, confirm you tested against the relevant one.

Documentation updated

  • Not needed (internal change)
  • Updated inline JSDoc / types
  • Updated docs/
  • External docs update needed (link issue or PR)

Em-dash check

  • No em dashes (--) or en dashes (-) in any added text (code, comments, docs, changelogs)

Checklist

  • Tests pass (pnpm test)
  • Types check (pnpm typecheck)
  • Lint clean (pnpm lint)
  • No new any types introduced
  • No console.log left in production code
  • Changeset added if user-visible (pnpm changeset)

Template shows a beforeAuthorize adapter that denies by default on error or timeout.
Idempotent on email, so the quickstart no longer inserts into theauth_users by hand.
Returns 401 for a missing or invalid agent token and 403 with the denial reason when the scope is not granted.
Provider, adapter, test and runtime dependency counts now come from scripts/stats.mjs.
Delegate, MCP call, out-of-scope denial, revoke and audit log in one runnable example.
Drops the hand-written theauth_users insert now that user.create ships.
Same email with a different id now throws a typed UserError, and unique violations are recovered without onConflictDoNothing.
Not wired yet. Defaults to a 2000ms timeout and deny on timeout or error.
Moves authorize and authorizeByToken out of theauth-core into src/authorize/pipeline.ts, and replaces reason-text matching with DECISION_CODES. Breaking: classification changes.
beforeAuthorize now runs after agent resolution with the delegation chain, covers authorizeByToken and policy.evaluate, times out and denies on error by default, and blocked calls write a chained audit row with a decision_code column. Breaking: see docs/upgrading-to-2.mdx.
authorize() checked status only, so an expired agent still passed. Now denied with agent_expired and an audit row. Breaking for agents that relied on the old behavior.
Deny by default on error or timeout, deny-overrides when composing several guards.
Resource and action strings are inferred from declared permissions. vitest config now runs the .test-d.ts type tests.
Adds an unhashed recorded_at_ms column (migration 0003) so same-second rows keep write order, and writes a chained delegation.revoke row per revoked link.
explain() reports the matched grant, delegation link and decision code with no side effects. The simulator now applies delegated constraints like authorize().
Action and resource are paired like authorize.
A delegation link now counts only if its delegator agent is active and unexpired. One filter feeds authorize, lineage, the MCP check and the simulator. Breaking: chains that passed before can now fail.
Moves the agent, audit and human-auth facades and plugin wiring into modules. theauth.delegation.revoke now accepts { revokedBy } so revoke audit rows record who revoked.
agentMayUse and loadGrants now use the shared filter, and a delegator with its own direct permissions keeps onward links its own authority covers. Breaking: vault access that succeeded before can now be refused.
Removes codes that are never emitted, adds the real delegation, user, token and OAuth codes, and drops the reserved wording on hook_timeout and hook_error.
Provider and adapter counts match docs/stats.json, delegation.create and createAgent samples use the real API, client README rewritten, llms files regenerated.
Comments and test titles use colons or commas. Test assertions that matched dashed text changed with them.
Move-only: scim, sso, openapi, passkey, oidc-provider, organization, presets, stripe, rebac, device-auth, federation and a2a types. Original paths still export the same names.
createTheAuthHandler, listRoutes, requireAgent and a Node bridge. Serves every advertised MCP route including new /mcp/revoke and /mcp/jwks, adds POST /explain, records the socket peer address out of band for client IP, and returns 403 for a foreign userId on audit export. Adds the ./http and ./testing subpath exports.
explain() returns the closest near-miss grants on a denial. @glinr/theauth/testing and theauth policy test run table-driven policy suites.
Adds theauth_schema_migrations with checksums, baseline stamping for existing databases, SchemaOutdatedError for skipMigrations, per-dialect generated SQL, a dialect suite for Postgres and MySQL (opt-in via env), and theauth db status|up|sql. schema.ts and migrations.ts split into modules. Audit hash inputs unchanged.
Each adapter is thin glue around createTheAuthHandler and exports requireScope driven by decision codes. Removes the five copied dispatch.ts files and the deprecated aliases. Breaking: option names unified, status codes unified (revoked token returns 401).
Signed POST of the hook context to a vendor endpoint, strict response schema, fails closed on network error, redirect, non-2xx or malformed body. verifyGuardRequest for vendors, theauth-conformance guard, and a reference server.
init detects the framework, seeds an owner with user.create and a demo agent on a SQLite file, never overwrites without --force. doctor adds schema, version and proxy checks and a --live mode. Templates use better-sqlite3 and generated secrets.
@thegdsks
thegdsks requested a review from a team as a code owner October 18, 2026 05:09
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your first pull request. CI will run shortly. If the change touches package source, please add a changeset with pnpm changeset.

}

};
router.use(handle);
app.use(express.json());
app.use(
"/api/auth/theauth",
buildTheAuthRouter(await makeTheAuth(), stubMcp, { allowUnauthenticated: true, ...extra }),
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
try {
const app = express();
app.use("/api/theauth", theAuthMiddleware({ theauth, allowUnauthenticated: true }));
app.use(express.json());
app.use(
"/api/theauth",
theAuthMiddleware({ theauth, authenticate: async () => ({ id: "admin" }) }),
Comment thread packages/core/src/http/router.ts Fixed
@thegdsks thegdsks changed the title Release/agent dx 2026 10 17 feat: agent auth batch for 2.0 Oct 18, 2026
@thegdsks
thegdsks merged commit a561306 into main Oct 18, 2026
7 of 10 checks passed
@thegdsks
thegdsks deleted the release/agent-dx-2026-10-17 branch October 18, 2026 05:49
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants