Skip to content

auth: add optional ID token to authenticate - #631

Merged
TylerLeonhardt merged 3 commits into
mainfrom
auth/optional-id-token
Nov 25, 2026
Merged

TylerLeonhardt merged 3 commits into
mainfrom
auth/optional-id-token

Conversation

@TylerLeonhardt

@TylerLeonhardt TylerLeonhardt commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Add an optional AuthenticateParams.idToken: the OpenID Connect ID Token that the authorization server issued with the access token, forwarded unchanged. It mirrors id_token in a token response, the same way expiresIn mirrors expires_in.

A host sometimes needs an identity claim about the account behind a token, such as its issuer or tenant. Today it has no standard way to get one:

  • The access token is opaque to everyone but its resource, and may be encrypted. scopes already exists so that hosts do not decode it.
  • accountId (auth: add optional account-selection hint #583) is opaque by definition, so a host must not parse it.

The ID Token is the artifact that is meant to be read. VS Code's agent host needs the Microsoft Entra tenant of the signed-in account for one of its agent providers, and would otherwise have to carry it in private metadata.

Protocol delta

Surface Addition
Existing AuthenticateParams Optional idToken: string, nonempty when present.

No capability, protocol-version change, new command, action or error. Older hosts ignore the field, and newer hosts keep accepting requests that omit it.

Semantics

The ID Token is client-supplied information about the account, not a credential. Hosts MUST NOT use it to authorize access, and its claims are unverified unless the host validates the token.

Open questions

  • Discovery. A client cannot tell whether a host wants the ID Token, so a client that supports the field sends identity claims to every host. Should a host be able to ask for it, for example on ProtectedResourceMetadata, instead?
  • Relation to auth: add client account identity and revocation notification #459. That proposal adds a structured account: { authority, id }. It does not carry tenant or other claims, so the two are complementary, but they should be reviewed together.

This PR and #607 both add a field after accountId, so whichever merges second needs a trivial rebase.

Validation

  • npm run generate — passed, with no further changes on a second run.
  • npm test — passed: 694 tests, including typecheck, lint, fragment and generated-output checks, schema tests and reducer coverage.
  • go test -count=1 ./... in clients/go — passed.
  • cargo test --workspace in clients/rust — passed.
  • Not run locally: the .NET, Kotlin and Swift clients. No container runtime was running for the pinned .NET and JDK images, and the machine has Command Line Tools without XCTest. Their changes are generated only; CI on this PR covers them.

Extend authenticate with an optional idToken, the OpenID Connect ID Token issued with the access token, so a host can read identity claims that the opaque access token and the opaque accountId do not expose. Document that it is not a bearer credential and that its claims are unverified. Regenerate native models and schemas, and cover the field in schema validation and a shared round-trip fixture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TylerLeonhardt
TylerLeonhardt marked this pull request as ready for review November 25, 2026 19:02
@TylerLeonhardt
TylerLeonhardt enabled auto-merge (squash) November 25, 2026 19:04
Comment thread docs/specification/authentication.md Resolved
Comment thread docs/specification/authentication.md Resolved
Comment thread types/common/commands.ts Resolved
State the purpose of idToken first, and keep only the host rule specific to AHP: it is client-supplied account information, not a credential. Drop the points an OpenID Connect consumer already knows and the notes that apply to any optional field.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TylerLeonhardt
TylerLeonhardt merged commit c6388cc into main Nov 25, 2026
8 checks passed
@TylerLeonhardt
TylerLeonhardt deleted the auth/optional-id-token branch November 25, 2026 20:07
Wing K.Y (wingwkyuen) pushed a commit to tcgoidc/vscode that referenced this pull request Nov 26, 2026
…icrosoft#350464)

* agentHost: forward the authentication ID token and learn the tenant

Forward the Microsoft session's ID token on authenticate, using the optional idToken field from microsoft/agent-host-protocol#631. The host keeps it with the accepted credential, replays it, and redacts it from AHP logs.

The Entra bridge reads the unverified tid claim from the first ID token sent for the account and keeps it with the account. Nothing is handed to the runtime yet: the identity result that carries the tenant is left as a TODO until the SDK accepts it.

Sync the protocol copy with idToken as a targeted backport on the current pin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: keep the ID token off sealed connections and track the accepted credential

Drop the ID token wherever the access token is sealed, since only the token can be sealed and a relay would otherwise read its claims.

Learn the tenant from the discovery credential that was just accepted, not from an older credential stored under the advertised scopes.

Include the ID token in the client's forwarded-credential key, so one that becomes available for an unchanged access token still reaches the host.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: send the ID token on relayed connections too

Stop dropping the ID token where the access token is sealed. An optional field that is silently omitted on one kind of connection is hard to notice, and the relay already carries the session's content in clear; the ID token is identity, not access.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* agentHost: simplify ID token handling after review

Move authenticate redaction into one function so the log replacer does not grow, share the nonempty-string check between accountId and idToken, and store the ID token the same way as the account ID.

Stop storing the ID token on host execution credentials, where nothing can read it, and keep the authority type private to the bridge.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants