Skip to content

feat(core): Snowflake Cortex OAuth login for V2 - #41111

Open
686f6c61 wants to merge 1 commit into
anomalyco:devfrom
686f6c61:snowflake-oauth
Open

feat(core): Snowflake Cortex OAuth login for V2#41111
686f6c61 wants to merge 1 commit into
anomalyco:devfrom
686f6c61:snowflake-oauth

Conversation

@686f6c61

@686f6c61 686f6c61 commented Aug 7, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #34780

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

V2 already has Snowflake Cortex as a catalog provider with PAT/env auth, but it never registered the browser OAuth login that V1 had. Without that, users cannot connect via Snowflake's external-browser OAuth, and the account-scoped Cortex host never ends up on the request.

This ports the V1 flow into the V2 snowflake-cortex plugin:

  • browser OAuth with account + optional role prompts
  • PKCE authorize/token exchange against https://{account}.snowflakecomputing.com
  • refresh using credential.metadata.accountId
  • store { accountId, baseURL } on the OAuth credential

It also teaches fromCatalogModel to apply OAuth routing metadata: for Snowflake, derive the Cortex OpenAI-compatible base URL from accountId (or use an explicit metadata.baseURL). Key credentials still project metadata into the request body; OAuth metadata is not dumped into the body.

Why this works: Snowflake OAuth is account-hosted, so refresh and API calls need the same account id that login captured. Putting that on credential metadata and resolving api.url at request time matches how V1 stashed accountId and built the host in the loader, without reintroducing a V1-style fetch monkey-patch for the native path.

How did you verify your code works?

  • bun test test/plugin/provider-snowflake-cortex.test.ts test/session-runner-model.test.ts (33 pass): method registration, account/role helpers, cortexFetch quirks, OAuth baseURL + bearer resolution
  • monorepo typecheck via pre-push hook
  • not runtime-tested against a real Snowflake tenant (no account available)

Screenshots / recordings

N/A (no UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Port account-scoped PKCE OAuth from the V1 plugin into the V2
snowflake-cortex provider: browser login with account/role prompts,
refresh via credential metadata, and request-time Cortex baseURL
resolution from OAuth accountId/baseURL so native openai-compatible
routes hit the correct host with a bearer access token.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@anujbolewar anujbolewar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks reasonable for a local oauth flow — pkce + a callback server bound to 127.0.0.1 is the standard safe pattern. one q: if the user misses the 5min window, do they just get an error or can they restart the flow cleanly?

@686f6c61

686f6c61 commented Aug 7, 2026

Copy link
Copy Markdown
Author

Good question.

On the 5-minute window they get a hard error from the OAuth callback: Snowflake OAuth callback timeout - authorization took too long. The local callback server is closed via the authorize-scope finalizer, so the port is released.

There is no mid-flow resume after that timeout: the failed attempt is discarded. Starting Login with Snowflake again runs a fresh authorize (new PKCE, state, and 127.0.0.1 listener), so the flow restarts cleanly without leftover callback state from the timed-out attempt.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V2: Snowflake Cortex OAuth login not supported

2 participants