feat(vscode): forward Copilot/gh tokens to Remote-SSH and dev containers#546
Open
DevSecNinja wants to merge 2 commits into
Open
feat(vscode): forward Copilot/gh tokens to Remote-SSH and dev containers#546DevSecNinja wants to merge 2 commits into
DevSecNinja wants to merge 2 commits into
Conversation
Make the 1Password token forwarding work in VS Code without per-repo changes: - copilot-ssh-proxy.sh: an `ssh` drop-in for VS Code's `remote.SSH.path`. For hosts matching COPILOT_SSH_HOST_PATTERN (default "svl") it reads the tokens from the 1Password Environment and adds `-o SendEnv=...`; all other hosts get a plain ssh (no 1Password unlock). This gets the tokens into the VS Code Server env so integrated terminals are authenticated. - devcontainer-prebuild.json: bake `remoteEnv` for COPILOT_GITHUB_TOKEN and GH_TOKEN into the shared dotfiles-devcontainer image metadata, so every repo using the image inherits it (merged per Dev Container spec) and the tokens reach inside dev containers with no per-repo devcontainer.json edits. - docs/copilot-cli.md: document the VS Code setup and the extension vs CLI distinction. - tests: add tests/bash/copilot-ssh-proxy.bats (matching/non-matching hosts, op-not-called scoping, GH_TOKEN-optional, custom pattern, op-absent fallback). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to #540: make the 1Password → SSH token forwarding work in VS Code too, so
copilotandghare authenticated in the integrated terminal over Remote-SSH and inside dev containers — with no per-repo changes.VS Code Remote-SSH connects with its own
sshinvocation, so it never goes through the interactivecopilot_sshhelper. Two centrally-managed pieces close that gap.Changes
home/dot_local/bin/copilot-ssh-proxy.sh— ansshdrop-in for VS Code'sremote.SSH.path. For hosts matchingCOPILOT_SSH_HOST_PATTERN(defaultsvl) it reads the tokens from the 1Password Environment and adds-o SendEnv=…; every other host gets a plainssh(no spurious 1Password unlock). This gets the tokens into the VS Code Server env → integrated terminals are authenticated..devcontainer/devcontainer-prebuild.json— bakeremoteEnvforCOPILOT_GITHUB_TOKEN/GH_TOKENinto the shareddotfiles-devcontainerimage metadata, so every repo using the image inherits it (merged per the Dev Container spec) and the tokens reach inside containers with no per-repodevcontainer.jsonedits. Resolves to empty (harmless) where absent (local/Codespaces).docs/copilot-cli.md— document the VS Code setup and the extension-vs-CLI distinction.tests/bash/copilot-ssh-proxy.bats— matching/non-matching hosts,op-not-called scoping, optionalGH_TOKEN, custom pattern, andop-absent fallback.Manual step (per workstation, not managed here)
Checklist
mise exec -- lefthook run pre-commit)