Skip to content

feat: better authentication UX — proactive key check & key discovery#2796

Open
ibetitsmike wants to merge 10 commits intomainfrom
fix/better-auth-ux
Open

feat: better authentication UX — proactive key check & key discovery#2796
ibetitsmike wants to merge 10 commits intomainfrom
fix/better-auth-ux

Conversation

@ibetitsmike
Copy link
Contributor

Summary

Implements both parts of #1:

Part 1: Ask for key before message

Shows an inline warning banner in the chat input area when the active workspace's model requires an unconfigured or disabled provider — before the user tries to send a message and gets an error.

  • Banner appears immediately on workspace select / model change
  • Shows "API key required for {provider}" or "Provider is disabled"
  • "Providers" button opens Settings → Providers for the relevant provider
  • Gateway-aware: suppressed when the model is routed through Mux Gateway

New files:

  • ProviderNotConfiguredBanner.tsx — banner component
  • ProviderNotConfiguredBanner.test.tsx — 15 tests

Part 2: Authentication stealing (key discovery)

New backend service scans known AI tool config locations for API keys and offers to import them during onboarding with explicit user consent.

Sources scanned:

  • Claude Code (~/.claude.json, ~/.config/claude/settings.json, ~/.claude/.env)
  • Codex CLI (~/.codex/config.json, ~/.codex/auth.json)
  • aider (~/.aider.conf.yml)
  • Continue.dev (~/.continue/config.json)
  • Shell RC files (.bashrc, .zshrc, .profile, .bash_profile)

Security:

  • Full keys never cross the IPC boundary — only masked previews
  • Import re-reads the source at import time (no caching of raw keys)
  • Config writes use existing Config.saveProvidersConfig() with mode: 0o600
  • Clear consent message shown before import

New files:

  • keyDiscoveryService.ts — backend scanner + import logic
  • keyDiscoveryService.test.ts — 27 tests

Modified files:

  • schemas/api.tsDiscoveredKeySchema, keyDiscovery.discover/import schemas
  • schemas.ts — barrel re-export
  • router.ts — oRPC handler implementations
  • OnboardingWizardSplash.tsx — conditional wizard step with checkboxes + consent
  • ChatInput/index.tsx — renders ProviderNotConfiguredBanner

Validation

  • tsc --noEmit — 0 errors
  • eslint — 0 errors
  • 50 tests pass (15 + 27 + 8 existing)

Closes #1

Implements both parts of #1:

1. Proactive auth check on workspace select: Shows an inline warning
   banner in the chat input when the active model's provider is not
   configured or is disabled, before the user tries to send a message.
   Gateway-aware — suppressed when the model is routed through Mux
   Gateway.

2. Key discovery from other AI tools: New backend service scans known
   config locations (Claude Code, Codex CLI, aider, Continue.dev,
   shell RC files) for API keys and offers to import them during
   onboarding. Full keys never cross the IPC boundary — only masked
   previews. Import requires explicit user consent.

Closes #1
Copy link

@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: 6fab410599

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

- Shell RC scanner now uses global regex to find the *last* matching
  export line, matching real shell behavior where later assignments
  override earlier ones (key rotation).
- Onboarding wizard pre-selects only the first discovered key per
  provider; duplicates require explicit user choice.
- Run prettier on all changed files.
Copy link
Contributor Author

@codex review

Copy link

@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: 77deb3d694

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

- Claude .env scanner: strip '# comment' and trailing ';' from values
- Shell RC regex: exclude ';' from captured token character class
- Added tests for both edge cases
Copy link
Contributor Author

@codex review

Copy link

@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: b327cf8b9b

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

- Banner uses 'not configured' instead of 'API key required' for
  keyless providers (bedrock, ollama).
- Aider YAML parser strips inline # comments from values.
- Added tests for both.
Copy link
Contributor Author

@codex review

Copy link

@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: 3939ec05c9

ℹ️ 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
Contributor Author

@codex review

Copy link

@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: 5eec6be9f7

ℹ️ 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
Contributor Author

@codex review

Copy link

@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: b566ce8ceb

ℹ️ 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
Contributor Author

@codex review

Copy link

@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: 029647089a

ℹ️ 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
Contributor Author

@codex review

Copy link

@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: dc1a6b8c96

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

- importDiscoveredKey accepts optional isProviderAllowed policy guard
- Router passes context.policyService check before import
- handleImportKeys skips already-successful entries
- Only the first selected source per provider is imported
Copy link
Contributor Author

@codex review

Copy link

@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: 5aef9d1dbf

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

Comment on lines +286 to +287
{ envVar: "GOOGLE_API_KEY", provider: "google" },
{ envVar: "GOOGLE_GENERATIVE_AI_API_KEY", provider: "google" },

Choose a reason for hiding this comment

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

P1 Badge Prefer generative Google env var when discovering shell keys

The shell scanner prioritizes GOOGLE_API_KEY before GOOGLE_GENERATIVE_AI_API_KEY, and because the loop short-circuits per provider (seen), a file that defines both will always import the former even when the latter is the intended active credential. That conflicts with runtime credential precedence (providerRequirements.ts prefers GOOGLE_GENERATIVE_AI_API_KEY first), so onboarding can import a stale Google key into providers.jsonc and then force auth failures because config keys override env fallbacks.

Useful? React with 👍 / 👎.

discover: t
.input(schemas.keyDiscovery.discover.input)
.output(schemas.keyDiscovery.discover.output)
.handler(() => discoverApiKeys()),

Choose a reason for hiding this comment

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

P2 Badge Filter discovered keys with policy before exposing them

The discover endpoint returns all discovered keys without checking policy, while import immediately rejects blocked providers via isProviderAllowed; in enforced-policy environments this surfaces disallowed provider key previews in onboarding and offers imports that are guaranteed to fail. Filtering at discovery time (or before rendering) would keep policy behavior consistent and avoid exposing blocked-provider credential metadata.

Useful? React with 👍 / 👎.

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.

Better authentication UX

1 participant