Repository navigation
官方 OAuth 改为槽终端登录 - #615
官方 OAuth 改为槽终端登录#615
Conversation
容器运行且 cli-node 已安装后,claude auth login 自己生成链接并换票。宿主机不再构造 claude_code 授权链接。
授权码由用户直接粘进终端,不再由面板中转。
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2fc774c. Configure here.
| ) : null} | ||
| </div> | ||
| </DialogContent> | ||
| </Dialog> |
There was a problem hiding this comment.
Terminal login never commits OAuth
High Severity
Claude Code login now only opens a slot terminal and runs claude auth login. It never calls generate-auth-url / exchange-code, so completeClaudeAuthLogin and commitImportedOauth never run. The CLI writes ~/.claude/.credentials.json, while the Go worker only owns credentials.json. The slot stays without imported tokens, identity, or schedulability after a successful paste.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2fc774c. Configure here.
没有 credentials.json 时先建空文件,再把官方 .credentials.json 链过去,避免登录写到 worker 读不到的独立文件。
Co-authored-by: ted <kuhlmangarry24@gmail.com>
集群节点、未运行容器和缺少 cli-node 的槽不能打开官方登录终端。凭证链接失败时终端不再继续启动。
Co-authored-by: ted <kuhlmangarry24@gmail.com>
普通运维 ticket 即使带 login=1 也不能升级成官方登录终端。
| for (const pid of [ptyPid, childPid]) { | ||
| if (pid && pidAlive(pid)) { | ||
| try { | ||
| process.kill(pid, 'SIGTERM') |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
stopClaudeAuthLoginSession 会读取 vms/<id>/run/auth-login 下的 pty.pid / child.pid,并对这些 PID 发送 SIGTERM/SIGKILL,而不校验它们是否真是本次拉起的 python PTY 或 docker exec。该目录经 /run/kin bind-mount 进入槽容器,且 run/ 会被 chown 给槽用户;槽内进程可以预先创建 auth-login 并写入任意宿主机 PID。控制面 systemd unit 未设 User=,通常以 root 发信号,可杀掉 PID 1、dockerd 或其他宿主机进程。同一可写目录里的 status.json 也可被改成钓鱼 auth_url,在植入的 PID 仍存活时被当成可复用会话。
Reviewed by Cursor Security Reviewer for commit 748da4d. Configure here.
| if (!fs.existsSync(workerFile)) { | ||
| if (!create) return { wrote: false, error: 'worker credentials.json missing' } | ||
| fs.mkdirSync(claudeDir, { recursive: true, mode: 0o700 }) | ||
| fs.writeFileSync(workerFile, '{}\n', { mode: 0o600 }) |
There was a problem hiding this comment.
🔒 Agentic Security Review
Severity: HIGH
新增 create: true 路径用 existsSync + writeFileSync 创建 credentials.json,二者都会跟随符号链接。本地槽把整个 cli-home bind 到 /home/kincli,没有集群节点上那种把 ~/.claude 嵌套挂成宿主机目录的保护。槽内可以把 credentials.json 换成指向宿主机路径的悬空 symlink;打开官方登录终端时,特权宿主机助手会把 { } 写到链接目标(随后还可能 chown 给槽 uid),从而在沙箱外创建或覆盖文件。
Reviewed by Cursor Security Reviewer for commit 748da4d. Configure here.
shell 只负责拿到票。会话结束时写入槽唯一使用的 credentials.json,并删除官方 CLI 的临时副本。
shell 拿到的票交给 commitImportedOauth。导入后 .credentials.json 继续链接到 worker 的 credentials.json,终端和槽使用同一份。




Summary
claude auth login。容器未运行或 cli-node 未安装时不打开登录。claude_code授权链接。Cookie 导入和 Setup Token 保持原路径。Test plan
node --test test/unit/claude-auth-login.test.mjs test/unit/oauth-auth-url.test.mjs test/unit/slot-shell-rc.test.mjsnode --test --test-name-pattern 'claude_code|generate-auth-url then|setup token' test/e2e/panel-api.e2e.test.mjspnpm -C web exec tsc --noEmit --pretty falseNote
High Risk
Changes authentication and OAuth credential handling (new session lifecycle, credential reads, and routing); mistakes could block login or mishandle tokens.
Overview
Claude Code OAuth no longer uses host-built authorize URLs. For flavor
claude_code, the panel starts an in-slotclaude auth loginsession (container running +cli-noderequired) via a new PTY helper andclaude-auth-login.mjs; PKCE, the CAI link, and token exchange stay inside the official CLI. HostgenerateAuthUrlnow errors onclaude_code, and exchange-code routes throughcompleteClaudeAuthLoginwhen appropriate.Panel UX shifts to the slot terminal. Users can open a dialog with
WsTerminal(login=1/KIN_PANEL_LOGIN) soclaude auth loginruns after the shell is ready; the authorize link and pasted code stay in the terminal instead of the credential form. The PTY path still supports feeding codes fromcode.inboxfor API-driven completion and copies full OAuth from the CLI’s credentials file with scope checks.Supporting changes:
cli-node-guardwhitelistsKIN_AUTH_LOGIN=1; tests and e2e expectations updated to reject pre-container login and document the new flow. Cookie import and setup-token paths are unchanged.Reviewed by Cursor Bugbot for commit 2fc774c. Configure here.