fix(auth): honor settings-based providers - #1326
Conversation
📝 WalkthroughWalkthroughThe change centralizes third-party provider classification and applies it to authentication detection, console command availability, auth-status reporting, and provider-gating regression tests. ChangesProvider gate classification and integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant ProviderSettings
participant getAPIProvider
participant isThirdPartyAPIProvider
participant AuthAndCommands
ProviderSettings->>getAPIProvider: provide configured API provider
getAPIProvider->>isThirdPartyAPIProvider: classify provider
isThirdPartyAPIProvider->>AuthAndCommands: return third-party status
AuthAndCommands->>AuthAndCommands: apply authentication and command gates
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f360ef0 to
b9f1cff
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/utils/auth.ts (1)
138-147: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winUpdate the stale rationale comment.
The comment at Line 139 lists "1. Using 3rd party services (Bedrock/Vertex/Foundry)" as a reason for
shouldDisableAuth. This item no longer applies here: theis3Pbranch was removed fromshouldDisableAuth, and third-party providers are now rejected by the earlierif (is3P) return falseat Line 123. Update the comment so it does not attribute third-party gating to code that no longer performs it in this block.📝 Proposed comment fix
- // Disable Anthropic auth if: - // 1. Using 3rd party services (Bedrock/Vertex/Foundry) - // 2. User has an external API key (regardless of proxy configuration) - // 3. User has an external auth token (regardless of proxy configuration) + // Disable Anthropic auth if (third-party providers already handled above): + // 1. User has an external API key (regardless of proxy configuration) + // 2. User has an external auth token (regardless of proxy configuration)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/utils/auth.ts` around lines 138 - 147, Update the rationale comment above shouldDisableAuth to remove the outdated third-party services item and describe only the external API key and external auth token conditions handled by this expression; leave the existing shouldDisableAuth logic and earlier is3P handling unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/utils/auth.ts`:
- Around line 138-147: Update the rationale comment above shouldDisableAuth to
remove the outdated third-party services item and describe only the external API
key and external auth token conditions handled by this expression; leave the
existing shouldDisableAuth logic and earlier is3P handling unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: e57aa172-7c28-4796-8bb7-422d17a5f592
📒 Files selected for processing (8)
src/cli/handlers/auth.tssrc/commands.tssrc/utils/auth.tssrc/utils/model/__tests__/providerGates.runner.tssrc/utils/model/__tests__/providerGates.test.tssrc/utils/model/__tests__/providers.test.tssrc/utils/model/providerClassification.tssrc/utils/model/providers.ts
Fixes #1325
根因
Console availability、auth status 与 Anthropic auth gate 使用了不一致的第三方判定。env provider 已由 #1235 覆盖,但
settings.modelType,尤其 Grok 路径,仍可能落入 first-party 分支。修复
isThirdPartyAPIProvider()分类 helper。getAPIProvider()的完整分类。claude auth status对 settings/env provider 统一输出third_party。isAnthropicAuthEnabled()对已确定的第三方 provider 直接返回 false,避免无意义的 Anthropic credential 探测。OPENAI_BASE_URL/GEMINI_BASE_URL兼容判断。isUsing3PServices()的 env-only 语义。/login、/logout继续使用原条件,不改变入口可见性。兼容性
first-party、六种
CLAUDE_CODE_USE_*env provider、OpenAI/Gemini base URL 及 settings OpenAI/Gemini/Grok 均有对照测试。auth status 的既有 credential probing 与 JSON 字段保持不变。测试
git diff --checkmain@987e550基线完整 CICI 证据:
b9f1cff9481f21041631d9c028ac2b2b9d8eec06Summary by CodeRabbit
Bug Fixes
Tests