Skip to content

feat: backwards compatible oauth for remote sessions#3005

Open
qstearns wants to merge 2 commits into
mainfrom
quinn/compat-oauth
Open

feat: backwards compatible oauth for remote sessions#3005
qstearns wants to merge 2 commits into
mainfrom
quinn/compat-oauth

Conversation

@qstearns
Copy link
Copy Markdown
Contributor

accidentally merged #2998 into the migration instead of main

@qstearns qstearns marked this pull request as ready for review May 22, 2026 18:58
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

⚠️ No Changeset found

Latest commit: 7b60e9e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@qstearns qstearns requested a review from a team as a code owner May 22, 2026 18:58
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

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

Project Deployment Actions Updated (UTC)
gram-docs-redirect Ready Ready Preview, Comment May 22, 2026 9:52pm

Request Review

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 66df5fb934

ℹ️ 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".

Copy link
Copy Markdown
Member

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take 2 LGTM 🚀

@speakeasybot
Copy link
Copy Markdown
Collaborator

speakeasybot commented May 22, 2026

🚀 Preview Environment (PR #3005)

Preview URL: https://pr-3005.dev.getgram.ai

Component Status Details Updated (UTC)
⏳ Database Pending Waiting for db-init job 2026-05-22 21:57:53.
✅ Images Available Container images ready 2026-05-22 21:57:51.

Gram Preview Bot

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 22, 2026
qstearns and others added 2 commits May 22, 2026 14:52
…istered clients (#2998)

I was hoping we would not need this, but there are enough manually set
up clients that have registered callback URLs in external systems that
it's worth supporting the old callback URL.

This PR does two things:

1. It makes the new auth challenge treat the old callback as a
jumpthrough enpdoint by passing it a special flag (telling it to
redirect to the new callback)
2. It automatically registers clients cloned from oauth_proxy_servers to
inherit this behavior. Once this change is live, we should be able to
migrate all remaining existing oauth proxy clients over to user sessions
(those that are receiving traffic at least)

Stacked on #2997.

- **Authorize** (`challenge.go`): when `client.LegacyCallbackUrl` is
true, set `redirect_uri = <serverURL>/oauth/callback` and wrap `state`
in a JSON envelope `{"remote_sessions":"true","state_id":"<id>"}` so the
upstream still matches its strict-registered redirect_uri. The stored
`RemoteLoginState.RedirectURI` matches, so the later token-endpoint
`redirect_uri` form param matches too.
- **Forward** (`oauth.handleAuthorizationCallback`): after parsing state
JSON, if `remote_sessions=true`, 302 to
`<serverURL>/mcp/remote_login_callback?state=<state_id>&code=…&error=…&error_description=…`.
The new handler finishes the exchange unchanged.
- **Clone** (`CloneClientFromOAuthProxyProvider`): every cloned proxy →
remote_session_client now persists `legacy_callback_url=true`, since the
upstream registration already points at `/oauth/callback`.

Deprecation plan lives in the schema comment from #2997 — when
`oauth_proxy_servers` is fully removed, `/oauth/callback` collapses to
just the forwarding shim, and once traffic to it drains, the column can
be dropped (expand-contract).

- [ ] `go build ./...` (server) — done locally
- [ ] Unit + e2e: a legacy-flagged client end-to-end (authorize →
upstream → `/oauth/callback` → `/mcp/remote_login_callback` → connect)
- [ ] Non-flagged clients still take the direct
`/mcp/remote_login_callback` path
- [ ] Cloning an oauth_proxy_provider produces a client with
`legacy_callback_url=true`

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…onClient

exhaustruct lint requires every field of CreateRemoteSessionClientParams
to be set explicitly. The non-clone CreateRemoteSessionClient handler was
relying on the zero value; spell out LegacyCallbackUrl: false so freshly
registered clients keep the default while the clone path retains true.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Spawn a preview environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants