Allow a credential command in providers.json and managed settings so BYOK providers work without a per-invocation launcher
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, nodejs, shell
- Lĩnh vực
- authentication, backend-api-design, cli, security
Hướng nghiên cứu
The issue involves modifying the provider configuration system in the Copilot CLI. Start by examining the code that loads providers.json and managed settings, likely in src/config or src/providers. Look for where apiKey and bearerToken are parsed. Understand the existing COPILOT_PROVIDER_API_KEY_COMMAND environment variable handling to replicate its semantics. Check the security requirements for command execution, logging, and caching. The change will touch multiple files including configuration parsing, credential fetching, and error handling. Verify by testing with a custom providers.json entry and a mock credential command.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the feature or problem you'd like to solve
Since 1.0.84, COPILOT_PROVIDER_API_KEY_COMMAND lets the CLI obtain a BYOK credential by running a command, so short-lived per-user tokens (OIDC/JWT from a gateway, Entra, STS, …) can rotate during a session. Thanks for that; it is the right primitive. (It isn't in changelog.md, and #3682, which requested it, is still open.)
The gap is that it only exists as an environment variable. The file-based surfaces have no equivalent:
providers.jsonentries accept only a staticapiKey/bearerToken.- Enterprise managed settings (MDM /
managed-settings.json) have no BYOK provider keys at all.
So anything that wants a rotating credential must set the environment before Copilot starts: a wrapper script, a shell alias, or a launcher process. Consequences:
- Plain
copilot(and anything else that spawnscopilot, e.g. IDE integrations, scripts,--acp) is not routed; only the wrapped invocation is. - Organizations cannot enforce "route through our gateway with your identity" via policy; the user has to remember to use the wrapper.
- Writing the rotating token into
providers.jsonasapiKeywould put a bearer credential on disk and defeat rotation.
Other coding agents already support this in their config files, which is why the same gateway integration is a static config drop for them but a launcher for Copilot CLI:
- Codex:
model_providers.<id>.auth = { command = "...", args = [...] }inconfig.toml/ managed config. - Claude Code:
apiKeyHelperinsettings.json/ managed settings. - Prior art elsewhere: Git/Docker credential helpers, AWS
credential_process, kubectl exec credential plugins.
Proposed solution
Provider registry: accept a command-based credential in providers.json provider entries, with the same semantics as COPILOT_PROVIDER_API_KEY_COMMAND (run to obtain the credential; cache; re-run near expiry and on 401, then retry once):
{
"providers": [
{
"name": "gateway",
"type": "openai",
"baseUrl": "https://gateway.example.com/v1",
"wireApi": "responses",
"apiKeyCommand": ["/usr/local/bin/agentdesktop", "credential", "--client-id", "copilot-cli"]
}
],
"models": [
{ "provider": "gateway", "id": "gpt-4.1", "modelId": "gpt-4.1", "wireModel": "gpt-4.1" }
]
}
(Field names other than apiKeyCommand should follow whatever the current providers.json schema uses. A bearerTokenCommand twin would mirror the existing apiKey / bearerToken pair.)
Prefer an argv array executed without a shell; optionally also accept a string executed like the env var does today.
Managed settings: allow the same provider definition (including the command) under enterprise managed settings, so an organization can pin the default provider and its credential source, and users cannot override it with a personal providers.json or env var.
Precedence: managed settings win when present; below that, keep env > providers.json > default, consistent with the flag > env > config ordering proposed in #2710. The env var keeps working as an override for ad-hoc use.
Security: never persist the command's output; redact it from logs, /collect-debug-logs, session state, and telemetry; run the command with a timeout and a bounded output size; treat non-zero exit as "no credential" rather than sending an empty bearer.
Example prompts or workflows
# Dropped once by MDM or a fleet agent, no per-user setup:
# ~/.copilot/providers.json the provider entry above
# ~/.copilot/settings.json { "model": "gateway/gpt-4.1" }
copilot # interactive
copilot -p "summarize this repo" # non-interactive
copilot --acp # spawned by an IDE or ACP client
All three route through the gateway with no wrapper or alias, and the token rotates for the life of the session.
Additional context
Related: #3682 , #3282, https://github.com/github/copilot-cli/issues/2710
- Ngôn ngữ chính
- Shell
- Star
- 11.2k
- Fork
- 1.9k
- Merge trung bình
- 14 giờ 16 phút
- Pull request đã merge (30 ngày)
- 6
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của github/copilot-cli
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
github/copilot-cli#4932 ·
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
github/copilot-cli#4909 ·
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
github/copilot-cli#4906 ·
-
triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
github/copilot-cli#4848 ·
-
area:agents area:mcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
github/copilot-cli#4729 ·
Tất cả issue của github/copilot-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#156 ·
-
Priority/High ready-for-agent Severity/Major Type/Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
comp/cli P3 type/docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#119756 · 1 bình luận ·
-
comp: build/pipeline type: bug version: current (v17+)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
angular/angularfire#3766 ·
-
out-of-date
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
CachyOS/CachyOS-PKGBUILDS#1903 ·