Skip to content

fix(cli): Route org-auth tokens to their instance - #1414

Open
BYK wants to merge 6 commits into
mainfrom
fix/1568-org-auth-host
Open

BYK wants to merge 6 commits into
mainfrom
fix/1568-org-auth-host

Conversation

@BYK

@BYK BYK commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Resolve Env org-auth token host claim ignored when picking request base URL cli#1568 in Toolkit by routing requests, web links, and trusted proxy headers through the active credential host unless an explicit Sentry URL takes precedence.
  • Pin credential identity and host across organization discovery, pagination, refresh, SDK calls, redirects, and response caching. Scope organization-region rows by credential and source origin; schema v17 discards rows without provable provenance.
  • Persist region rows only after every organization page succeeds, fetch discovery responses with verified provenance, and retain pinned OAuth sessions across refresh-token rotation without admitting another login. Derive cache keys with HMAC-SHA-256 keyed by the credential fingerprint.
  • Preserve self-hosted installation paths in region URLs, document token-claim routing, and cover migration, concurrent logins, redirects, refresh, and cache behavior with regressions.

Supersedes getsentry/cli#1575.

Validation

  • CLI unit suite: 10,309 passed, 13 skipped; targeted cache/discovery tests after the latest cache-key change: 48 passed.
  • CLI typecheck and Biome, root typecheck and lint/ast-grep, and generated-definition checks passed. Root lint reports two pre-existing MCP Cloudflare warnings.
  • Exact-head GitHub checks are running.

Pin active credentials across organization discovery, region routing, refresh, redirects, and response caching. Scope region metadata by credential and source host; retain self-hosted installation paths and validate boot-time host migration.

Co-Authored-By: GPT-6 Sol <noreply@openai.com>
Comment thread packages/cli/src/lib/response-cache.ts Fixed

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eb42e75. Configure here.

Comment thread packages/cli/src/lib/api/organizations.ts
Comment thread packages/cli/src/lib/custom-headers.ts
Comment thread packages/cli/src/lib/sentry-urls.ts
Comment thread packages/cli/src/lib/api/organizations.ts Outdated
Comment thread packages/cli/src/lib/api/organizations.ts Outdated
Comment thread packages/cli/src/lib/db/auth.ts
BYK and others added 3 commits October 5, 2026 21:13
Preserve self-hosted paths in organization region fallbacks, use the active host for proxy headers and web links, and refresh generated skill metadata. Use a full SHA-256 namespace for credential-scoped caches.

Co-Authored-By: GPT-6 Sol (OpenAI) <noreply@openai.com>
Cache organization regions only after every page completes, require fresh provenance for discovery, and retain pinned OAuth sessions across refresh-token rotation.

Co-Authored-By: OpenAI gpt-6-sol <noreply@openai.com>
Use the credential fingerprint as an HMAC key to partition cache entries without treating credentials as password hashes.

Co-Authored-By: OpenAI gpt-6-sol <noreply@openai.com>
Comment thread packages/cli/src/lib/oauth.ts
Use the actual request origin in network and TLS diagnostics so self-hosted refresh failures identify the instance that failed.

Co-Authored-By: OpenAI gpt-6-sol <noreply@openai.com>
@github-actions github-actions Bot added risk: high PR risk score: high and removed risk: high PR risk score: high labels Oct 5, 2026
Comment thread packages/cli/src/lib/api/organizations.ts
Keep trusted region routes without allowing missing or invalid region metadata to turn a partial org list into an authoritative cache hit.

Co-Authored-By: OpenAI gpt-6-sol <noreply@openai.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Env org-auth token host claim ignored when picking request base URL

2 participants