Repository navigation
Accept ChatGPT's issuer-identification OAuth redirect - #189
Merged
Merged
Conversation
The OpenAI directory submission failed at the MCP-details step with `invalid_redirect_uri`: DCR refused `https://chatgpt.com/connector_platform_oauth_redirect`, since the only path pinned for `chatgpt.com` was `/connector/oauth/`. OpenAI's two callback forms are not legacy and current, as the submission doc assumed, but conditional on the authorization server. ChatGPT sends `/connector/oauth/{callback_id}` only to a server without issuer identification, and the stable `/connector_platform_oauth_redirect` to one advertising `authorization_response_iss_parameter_supported` — which our AS metadata does, so the stable path is the one a ChatGPT connection actually registers with us. Pin both paths in `DEFAULT_ALLOWED_REDIRECTS`. The new entry is an exact vendor OAuth endpoint, the same shape as the `claude.ai` entry, so the CWE-601 path pin is unchanged: no user-content path on the origin becomes registrable, and `hosted_redirect_allow_list` covers the near-miss (`…_redirectEVIL`) alongside the positive. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd7VT72Qt16qiAJynu9EKj
There was a problem hiding this comment.
🟡 Changes recommended
The new supposedly exact callback entry also permits arbitrary descendant paths.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds support for ChatGPT’s issuer-identification OAuth callback.
Changes:
- Allows the stable ChatGPT redirect URI.
- Adds positive and near-miss tests.
- Updates submission documentation.
File summaries
| File | Description |
|---|---|
src/auth.rs |
Adds and tests the callback allow-list entry. |
docs/openai-directory-submission.md |
Documents ChatGPT’s callback-selection behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
sea-snake
previously approved these changes
Sep 3, 2026
Review found that the new entry was not exact as its comment claimed: `path_within_prefix` accepts any segment-boundary descendant, so DCR would also have admitted `/connector_platform_oauth_redirect/anything`. Correct, and broader than the single stable endpoint this trusts. Make the matching mode a per-entry property (`PathPin::Exact` / `PathPin::Prefix`) instead of an implicit property of the matcher, and pin the new entry `Exact`. The nine pre-existing entries keep `Prefix`, so their behaviour is byte for byte unchanged. Tightening any of them is a separate, deliberate decision: `redirect_uri_permitted` is re-checked at `/oauth/authorize`, not only at registration, so narrowing a vendor that appends a path segment would break its already-registered clients mid-flow. The doc block says so, and says env entries stay prefixes, as `OAUTH_ALLOWED_REDIRECT_PREFIXES` implies. Tests: the descendant negative review asked for, plus `path_pin_modes` covering both modes, that ChatGPT's stable callback is `Exact`, and the invariant that a trailing-slash entry is never `Exact` (where it would match only a path ending in `/`, pinning nothing). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Xd7VT72Qt16qiAJynu9EKj
sea-snake
approved these changes
Sep 3, 2026
6 of 7 tasks
aterga
added a commit
that referenced
this pull request
Sep 3, 2026
* Check in rustfmt.toml so `cargo fmt --all` matches the tree CONTRIBUTING.md and the pull request template both ask for `cargo fmt --all` before opening a PR, and the coding guidelines ask to "keep the tree `rustfmt`-clean" — but no rustfmt config was checked in anywhere, and the tree was not clean. On stable 1.94.1 the documented step rewrote 18 files (4473 insertions, 1202 deletions): rustfmt's stock `fn_call_width` and `chain_width` of 60 split the calls and method chains this codebase keeps on one line. Following the instructions therefore meant either shipping a whole-repo reformat or hand-matching the surrounding style and skipping the step, which is what happened while preparing #189. No configuration reproduces the tree exactly, because the tree was never rustfmt output. A coordinate-descent sweep over every stable width knob (`max_width`, the six `use_small_heuristics` sub-widths, `fn_params_layout`, `style_edition`) bottoms out around 5700 residual diff lines, and the best-fitting combination is a curve fit to inconsistent hand formatting rather than a style anyone chose. 403 checked-in lines exceed 100 columns, among them breakable code such as `resolve_did` in `calls.rs` at 103 — a signature rustfmt would never emit at `max_width = 100`. So this checks in the two settings that are defensible on their own: the 100-column budget the code is visibly written to (the line-length histogram falls off a cliff there), and the widened heuristics that keep chains intact, which is the difference the report of this problem identified. Being unable to recover a config does not leave the repo stuck: one reviewed reformat ends drift that otherwise recurs for every contributor. The residual reformat those settings still want is applied here and nothing else, so it is reviewable on its own — 25 files, 1661 insertions, 1482 deletions, against 4473/1202 with no config at all. Purely whitespace and line breaks plus rustfmt's import ordering; `cargo build`, `cargo test` (270 tests) and the 11 pre-existing clippy warnings are unchanged. After it, `cargo fmt --all -- --check` is clean and idempotent on a fresh clone. If maintainers format with a toolchain or editor setting that is not in the repo, that config should be preferred over this one — it can be swapped in and the reformat redone against it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FefdMpLRBQ7cLihuQsi3Mf * Add a formatting check to CI CI ran build, test, the PocketIC e2e suite and the internal-identifier scan, but nothing checked formatting — so the rustfmt-clean tree CONTRIBUTING.md asks for was a request with no enforcement behind it, and it had already stopped being true. Checking in `rustfmt.toml` fixes the tree once; this is what keeps it fixed, because without it the drift just recurs and the next contributor to run the documented `cargo fmt --all` inherits someone else's reformat. A separate `fmt` job rather than a step in `test`: the two failures are independent and each should stay readable when the other fires, and since the job compiles nothing it runs in seconds in parallel, adding no wall-clock. `--check` only reports, never rewrites, and the local reproduction is the `cargo fmt --all` already documented. No new third-party action: this reuses `actions/checkout` at the same pinned SHA as the other jobs, and takes rustfmt from the runner's rustup like they take cargo. The toolchain is rolling `stable`, matching the sibling jobs, which does mean a stable release that changes rustfmt's output can turn this red with no code change — the comment records that the fix then is to re-run `cargo fmt --all`, not to pin. Verified against this branch: the check passes on the formatted tree, and fails as intended when deliberate drift is introduced. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FefdMpLRBQ7cLihuQsi3Mf * Fix the article in the fmt job's comment Review nit: "an rustfmt-clean tree" should be "a rustfmt-clean tree" — `rustfmt` starts with a consonant sound, so "an" is wrong. Comment text only; the job itself is unchanged. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FefdMpLRBQ7cLihuQsi3Mf --------- Co-authored-by: Claude Opus 5 <[email protected]>
9 tasks done
3 of 7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAI directory submission fails at the MCP-details step:
That 400 is ours.
DEFAULT_ALLOWED_REDIRECTSpinned only("chatgpt.com", "/connector/oauth/"), andpath_within_prefixmatches at segment boundaries, so that prefix can never admit/connector_platform_oauth_redirect.The submission doc recorded
/connector_platform_oauth_redirectas a legacy URI deliberately left out of the allow-list, to be added viaOAUTH_ALLOWED_REDIRECT_PREFIXESonly "if a reviewer reports a failure." That premise was wrong. Per OpenAI's Apps SDK auth docs the two forms are not old and new but conditional on the authorization server:https://chatgpt.com/connector/oauth/{callback_id}https://chatgpt.com/connector_platform_oauth_redirectauthorization_response_iss_parameter_supportedOur AS metadata advertises
authorization_response_iss_parameter_supported: true, so the stable path is the form a ChatGPT connection actually registers with us — which is exactly what DCR was rejecting. Our own correct hardening and our own correct metadata combined into the rejection.Both paths are now pinned, so neither needs a deploy-time env entry.
Security
The CWE-601 path pin the
DEFAULT_ALLOWED_REDIRECTSdoc block describes is tightened here, not loosened.Review (#discussion_r3924369843) caught that the first version of this change was not exact as its comment claimed:
path_within_prefixaccepts any segment-boundary descendant, so DCR would also have admitted/connector_platform_oauth_redirect/anything. Matching mode is now a per-entry property —PathPin::ExactvsPathPin::Prefix— instead of an implicit property of the matcher, and ChatGPT's stable callback is pinnedExact. No descendant of it is registrable, and no user-content path on thechatgpt.comorigin (/g/…,/share/…) ever was.The nine pre-existing entries keep
Prefix, so their behaviour is byte for byte unchanged. Tightening any of them is a separate, deliberate decision:redirect_uri_permittedis re-checked at/oauth/authorize, not only at registration, so narrowing a vendor that appends a path segment would break its already-registered clients mid-flow.OAUTH_ALLOWED_REDIRECT_PREFIXESentries also stay prefixes, as the variable name implies.The percent-encoding and dot-segment defenses are untouched and still covered by the existing assertions.
Related issues
Surfaced by the live submission attempt for the ChatGPT Plugins Directory; context in
docs/openai-directory-submission.md.Changes
src/auth.rs— add("chatgpt.com", "/connector_platform_oauth_redirect", PathPin::Exact)toDEFAULT_ALLOWED_REDIRECTS, with a comment recording why both ChatGPT paths are pinned.src/auth.rs— introducePathPinso an entry declares whether its path matches exactly or as a prefix;redirect_uri_permittedhonours it. Existing entries and env entries arePrefix, preserving current behaviour.src/auth.rs— extendhosted_redirect_allow_listwith the positive case, the non-segment-boundary near-miss (…_redirectEVIL) and the descendant negative (…_redirect/anything); addpath_pin_modescovering both modes, theExactpin on ChatGPT's stable callback, and the invariant that a trailing-slash entry is neverExact.docs/openai-directory-submission.md— correct the readiness row and replace the "legacy redirect" note with the actual rule.Testing
cargo build --locked --workspace --all-targetscargo test --locked --workspace --all-targets— 270 tests, 0 failurescargo clippy --workspace --all-targets— the 9 warnings are pre-existing inimcp2-core(calls.rs,discover.rs,tools.rs,management.rs); none insrc/auth.rs, and this change adds nonenpm test --prefix monitoring/mcp-status— not run; the dashboard is untouchedBoth fixes were reproduced before being made. Removing the allow-list entry while keeping the new assertions fails
hosted_redirect_allow_listat the positive case; flipping the entry fromExacttoPrefixfails both the descendant negative andpath_pin_modes. The live 400 was also confirmed directly againsthttps://mcp.internetcomputer.org/mcp/oauth/register, wherehttps://claude.ai/api/mcp/auth_callbackregisters201while all four ChatGPT paths returnedinvalid_redirect_uri.A note on
cargo fmt --all: it is not run here. Under stable 1.94 defaults it rewrites 19 files / ~4.5k lines across the whole workspace, and even withuse_small_heuristics = "Max"it still wants ~6.3k lines, so the tree is not clean under any inferable config and norustfmt.tomlis checked in. The added lines were hand-matched to the surrounding style instead (≤100 columns, wide call style; assertions that would exceed 100 are wrapped the way their neighbours are). Worth settling separately by checking in the config the tree was formatted with.Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xd7VT72Qt16qiAJynu9EKj