Repository navigation
[v1.x] fix(client/auth): avoid duplicate prompt query parameter in startAuthorization - #3275
Conversation
🦋 Changeset detectedLatest commit: 6c7d287 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c7d287c19
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // we need to set the prompt to "consent" to ensure the user is prompted to grant offline access | ||
| // https://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess | ||
| authorizationUrl.searchParams.append('prompt', 'consent'); | ||
| authorizationUrl.searchParams.set('prompt', 'consent'); |
There was a problem hiding this comment.
Preserve account-selection prompts when adding consent
When offline_access is requested and the advertised authorization endpoint has prompt=select_account, this replaces that directive with only consent, so the provider no longer receives the request to show an account picker and may authorize the default signed-in account. OIDC allows compatible prompt directives to share a space-delimited value, so keep the existing directive in the single parameter rather than discarding it.
Useful? React with 👍 / 👎.
Summary
Backports the fix from #1958 onto
v1.xto resolve #3274.When
startAuthorizationis called withoffline_accessscope against an authorization server whose advertisedauthorization_endpointmetadata already contains apromptquery parameter (such as Okta/Brex?prompt=consentor Entra ID?prompt=select_account),authorizationUrl.searchParams.append('prompt', 'consent')emitted twopromptparameters on the resulting URL. That violates RFC 6749 §3.1 and causes authorization servers to reject the request before sign-in.All other OAuth query parameters in
startAuthorization(response_type,client_id,code_challenge,code_challenge_method,redirect_uri,state,scope,resource) already usesearchParams.set(). Changing.append('prompt', 'consent')to.set('prompt', 'consent')aligns theoffline_accessbranch with the rest ofstartAuthorizationand ensures a singleprompt=consentparameter per OIDC Core §11.Fixes #3274
Changes
src/client/auth.ts: UseauthorizationUrl.searchParams.set('prompt', 'consent')inside theoffline_accessbranch instartAuthorization.test/client/auth.test.ts: Added regression coverage verifying a singleprompt=consentparameter whenauthorization_endpointalready includes?prompt=consentor?prompt=select_account, and preserving existingpromptquery parameters whenoffline_accessis omitted..changeset/fix-v1-start-authorization-prompt.md: Added patch changeset for@modelcontextprotocol/sdk.Verification
npm run lint(eslint src/+prettier --check .) — passednpx tsc --noEmit— passednpm run build(build:esm+build:cjs) — passednpx vitest run --maxWorkers=2 test/client/auth.test.ts— 161/161 passed