Repository navigation
feat: gh-read, read-only gh with the owner's Coder GitHub login for runner sessions - #267
Merged
Merged
Conversation
…unner sessions
Claude Code runner sessions get a proxied gh and GitHub MCP tools that reach
only the repositories attached to the session, so reading issues, PRs and
comments in other repositories (socktainer/socktainer, libracoder/kiri)
fails with 403. gh-read runs the real gh with the token from Coder external
auth ("coder external-auth access-token github"), so each workspace owner
reads GitHub as themselves without gh auth login. It accepts only read
commands; /etc/claude-code/CLAUDE.md tells sessions to use it, and a managed
permission rule allows it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UrTUMxoyzqiN3JtHacV96S
PreviewsThe start.coder.ddev.com landing-page preview has been removed. Read the Docs keeps or removes its own docs preview. |
…de Coder Self-hosted runners outside Coder, such as the macOS one, have no external auth. There gh-read now takes a read-only token from the macOS Keychain item gh-read-token, or from ~/.config/gh-read/token (mode 600), and finds gh in /opt/homebrew/bin. Coder workspaces keep using the owner's Coder login. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UrTUMxoyzqiN3JtHacV96S
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.
The Issue
Claude Code runner sessions get a proxied
ghand GitHub MCP tools that reach only the repositories attached to the session. Search works across GitHub, but reading an issue, PR, comment thread, file or CI run anywhere else fails with 403 ("GitHub access to this repository is not enabled for this session"). Recent examples weresocktainer/socktainerandlibracoder/kiri.add_repocan't fix it for third-party repositories, because API access needs the Claude GitHub App installed on them. Each person runninggh auth loginin their workspace would work, but it's setup every team member has to repeat, and it gives sessions a broad token.How This PR Solves The Issue
gh-readin~/.local/bin: runs the realghwith the workspace owner's token from Coder's GitHub external auth (the one the Drupal templates already use for Composer), with an empty gh config dir. Every owner reads GitHub as themselves, with nogh auth login; linking GitHub once in Coder is enough.issue/prview, list, diff, checks;search;repo/run/release/workflowview and list;apiwith GET, and GraphQL queries. It refuses other methods,-f/-Fwithout-X GET,--input, GraphQL mutations,authand everything else. This guards against mistakes; the token's real limits come from the GitHub App behind Coder's external auth. With the App not installed on any account, its user tokens can only read public repositories./etc/claude-code/CLAUDE.mdtells every runner session to usegh-readfor repositories outside the session, and to keep the session's ownghor MCP tools for writes. A managed permission rule allowsBash(gh-read:*).Manual Testing Instructions
freeformand create a workspace with the runner enabled and an environment secret; link GitHub at<coder URL>/external-auth/github.gh-read issue list -R socktainer/socktainer -L 2andgh-read pr diff 894 -R libracoder/kirireturn data;gh-read pr comment 1 -R x/y -b hiis refused.gh-read.Done on staging-coder.ddev.com (template version
gh-read-3, combined with #266): the session usedgh-readfor all three GitHub calls with no permission prompt (auto mode), and never fell back toadd_repoor WebFetch. Before linking GitHub,gh-readprints the link URL and exits.Automated Testing Overview
None added.
shellcheckpasses ongh-read.terraform fmtandmake validateweren't run here (no Terraform in this workspace); CI runs them.Release/Deployment Notes
The runner README section that says a session's
ghis the workspace's ownghis out of date (sessions now put a proxiedghfirst on PATH); that's left for a separate fix. This PR and #266 both touchmanaged_settingsand the runner README, so the second to merge needs a small rebase.Generated by Claude Code