Skip to content

fix(register): resolve host JWT iss against id or kid - #29

Merged
Paola3stefania merged 5 commits into
mainfrom
fix/register-dual-host-lookup
May 15, 2026
Merged

fix(register): resolve host JWT iss against id or kid#29
Paola3stefania merged 5 commits into
mainfrom
fix/register-dual-host-lookup

Conversation

@Paola3stefania

@Paola3stefania Paola3stefania commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Per spec §4.2, the SDK signs host JWTs with iss = JWK thumbprint. For hosts created via the enrollment-token flow, the thumbprint is stored in the kid column, not id. The middleware already does a dual lookup:

const host =
  (await db.findHostById(hostIdFromIss)) ?? (await db.findHostByKid(hostIdFromIss));

…but /agent/register and /agent/claim only looked up by id. Pre-enrolled hosts therefore missed the lookup, fell through to the dynamic-registration branch, and threw dynamic_host_registration_disabled whenever the operator had set allowDynamicHostRegistration: false.

There was also a follow-on bug in the same routes: after signature verification they checked payload.iss !== hostRecord.id, which would still reject a kid-resolved host even after the lookup was fixed. Both checks are now payload.iss !== hostRecord.id && payload.iss !== hostRecord.kid.

No public API changes. No schema changes. Patch-level release.


Reported on Discord by jtavares (2026-04-20).

@vercel

vercel Bot commented Apr 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-auth-agent-coffee Ready Ready Preview, Comment May 15, 2026 7:07pm
agent-auth-agent-deploy Ready Ready Preview, Comment May 15, 2026 7:07pm
agent-auth-directory Ready Ready Preview, Comment May 15, 2026 7:07pm
agent-auth-gmail-proxy Ready Ready Preview, Comment May 15, 2026 7:07pm
agent-auth-stripe-agents Ready Ready Preview, Comment May 15, 2026 7:07pm
agent-auth-vercel-proxy Ready Ready Preview, Comment May 15, 2026 7:07pm

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Apr 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@better-auth/agent-auth@29
npm i https://pkg.pr.new/@auth/agent-cli@29
npm i https://pkg.pr.new/@auth/agent@29

commit: 189ad82

@Paola3stefania
Paola3stefania merged commit 55b218c into main May 15, 2026
5 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant