diff --git a/README.md b/README.md index b1585e34..021c92eb 100644 --- a/README.md +++ b/README.md @@ -603,23 +603,6 @@ npm run service:status - 客户端验证失败时会返回403错误并记录详细信息 - 通过日志可以查看实际的User-Agent格式,方便配置自定义客户端 -### 自定义客户端配置 - -如需添加自定义客户端,可以修改 `config/config.js` 文件: - -```javascript -clientRestrictions: { - predefinedClients: [ - // ... 现有客户端配置 - { - id: 'my_custom_client', - name: 'My Custom Client', - description: '我的自定义客户端', - userAgentPattern: /^MyClient\/[\d\.]+/i - } - ] -} -``` ### 日志示例 diff --git a/config/config.example.js b/config/config.example.js index 3f8d71d7..adb17ec6 100644 --- a/config/config.example.js +++ b/config/config.example.js @@ -113,38 +113,6 @@ const config = { sessionSecret: process.env.WEB_SESSION_SECRET || 'CHANGE-THIS-SESSION-SECRET' }, - // 🔒 客户端限制配置 - clientRestrictions: { - // 预定义的客户端列表 - predefinedClients: [ - { - id: 'claude_code', - name: 'ClaudeCode', - description: 'Official Claude Code CLI', - // 匹配 Claude CLI 的 User-Agent - // 示例: claude-cli/1.0.58 (external, cli) - userAgentPattern: /^claude-cli\/[\d.]+\s+\(/i - }, - { - id: 'gemini_cli', - name: 'Gemini-CLI', - description: 'Gemini Command Line Interface', - // 匹配 GeminiCLI 的 User-Agent - // 示例: GeminiCLI/v18.20.8 (darwin; arm64) - userAgentPattern: /^GeminiCLI\/v?[\d.]+\s+\(/i - } - // 添加自定义客户端示例: - // { - // id: 'custom_client', - // name: 'My Custom Client', - // description: 'My custom API client', - // userAgentPattern: /^MyClient\/[\d\.]+/i - // } - ], - // 是否允许自定义客户端(未来功能) - allowCustomClients: process.env.ALLOW_CUSTOM_CLIENTS === 'true' - }, - // 🔐 LDAP 认证配置 ldap: { enabled: process.env.LDAP_ENABLED === 'true', diff --git a/src/validators/clientDefinitions.js b/src/validators/clientDefinitions.js index b2402fa6..b70e3474 100644 --- a/src/validators/clientDefinitions.js +++ b/src/validators/clientDefinitions.js @@ -9,9 +9,6 @@ const CLIENT_DEFINITIONS = { name: 'Claude Code', displayName: 'Claude Code CLI', description: 'Claude Code command-line interface', - userAgentPattern: /^claude-cli\/[\d.]+(?:[-\w]*)?\s+\(external,\s*(?:cli|sdk-[a-z]+)\)$/i, - requiredHeaders: ['x-app', 'anthropic-beta', 'anthropic-version'], - restrictedPaths: ['/api/v1/messages', '/claude/v1/messages'], icon: '🤖' }, @@ -20,9 +17,6 @@ const CLIENT_DEFINITIONS = { name: 'Gemini CLI', displayName: 'Gemini Command Line Tool', description: 'Google Gemini API command-line interface', - userAgentPattern: /^GeminiCLI\/v?[\d.]+/i, - requiredPaths: ['/gemini'], - validatePaths: ['generateContent'], icon: '💎' }, @@ -31,9 +25,6 @@ const CLIENT_DEFINITIONS = { name: 'Codex CLI', displayName: 'Codex Command Line Tool', description: 'Cursor/Codex command-line interface', - userAgentPattern: /^(codex_vscode|codex_cli_rs)\/[\d.]+/i, - requiredHeaders: ['originator', 'session_id'], - restrictedPaths: ['/openai', '/azure'], icon: '🔷' } }