feat(oauth): make the refresh_token grant opt-out per server

The Inspector always declared `refresh_token` in its OAuth client
metadata. The SDK's `determineScope()` then appends `offline_access`
whenever the authorization server advertises it and the client declares
that grant, and `startAuthorization()` appends `prompt=consent` whenever
`offline_access` is in scope. Against Microsoft Entra ID that forced
consent prompt routes a non-admin user into the admin-consent workflow
and fails with AADSTS90094 — even after a tenant admin has consented.

Adds a per-server "Request refresh token" setting (default on) that
drops the grant from the client metadata, breaking that chain at its
source. Persisted as `oauth.requestRefreshToken` and written only when
off, so entries that never touch it keep a byte-stable round-trip. Web
edits it in Server Settings → Authorization; the CLI and TUI pick it up
from the same per-server settings via `buildRunnerClientAuthOptions`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013hzwzS8UvBsr4yZm7o7sev
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
cliffhall 2026-08-24 19:50:57 -04:00
commit e2fb78d999

View file

@ -555,6 +555,12 @@ export function storedFieldsToInspectorSettings(
if (stored.oauth?.enterpriseManaged === true) {
settings.enterpriseManaged = true;
}
// Inverted from the flags above: the default is *on*, so only an explicit
// `false` is carried through. Anything else on disk (absent, or a
// hand-edited non-boolean) reads back as unset, i.e. the default. (#2068)
if (stored.oauth?.requestRefreshToken === false) {
settings.oauthRequestRefreshToken = false;
}
// Mirror the stdio working directory for the form. Like the OAuth fields, an
// empty string coerces to absent so the form's "(inherit)" placeholder shows.
if (stored.cwd) settings.cwd = stored.cwd;
@ -682,6 +688,12 @@ export function inspectorSettingsToStoredFields(
if (settings.enterpriseManaged === true) {
oauthFields.enterpriseManaged = true;
}
// Only the non-default (off) is written; an absent field reads back as the
// default (on), so writing `true` would inject the key into files that never
// set it and break byte-stable round-trips. (#2068)
if (settings.oauthRequestRefreshToken === false) {
oauthFields.requestRefreshToken = false;
}
if (Object.keys(oauthFields).length > 0) {
out.oauth = oauthFields;
}