Skip to content

Commit 68aef83

Browse files
AlexShchukaAleksandr Shchukaclaude
authored
fix(ghauth): persist device-flow token with --insecure-storage (#111)
## What Add `--insecure-storage` to the in-container `gh auth login --web` invocation. ## Why `gh auth login --web` defaults to the system keyring. The sandbox has no keyring/D-Bus, so a freshly built container (gh 2.93) fails **right after the browser grant** — the token is never written, `~/.config/gh` stays empty, and `mirabilis launch` dies with `GitHub sign-in — exit status 1`. An older gh stored to a file by default, which is why sign-in used to work before a rebuild. `--insecure-storage` writes the token to a file in the persistent `gh-config` volume — the storage this design already depends on (a keyring token wouldn't survive a container rebuild anyway, and the container *is* the security boundary per `SECURITY.md`). ## Verification In the live locked-down container, piping a token through the file-storage path logs in cleanly (`exit 0`, token in `hosts.yml`); the keyring default is the only thing that breaks. `go build ./...`, `gofmt`, `go vet`, and `go test ./internal/ghauth/...` are green. Refs cli/cli#10108. Co-authored-by: Aleksandr Shchuka <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent 05c4c44 commit 68aef83

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎internal/ghauth/ghauth.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func (g *Model) readNext() tea.Msg {
8484
func loginArgs() []string {
8585
return []string{"env", "BROWSER=true",
8686
"gh", "auth", "login", "--hostname", "github.com",
87-
"--git-protocol", "https", "--web", "--scopes", "workflow"}
87+
"--git-protocol", "https", "--web", "--scopes", "workflow",
88+
"--insecure-storage"}
8889
}
8990

9091
func (g *Model) run() {

‎internal/ghauth/ghauth_test.go‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ func TestLoginArgsRequestWorkflowScope(t *testing.T) {
7373
}
7474
}
7575

76+
func TestLoginArgsUsesInsecureStorage(t *testing.T) {
77+
args := loginArgs()
78+
for _, a := range args {
79+
if a == "--insecure-storage" {
80+
return
81+
}
82+
}
83+
t.Errorf("loginArgs must pass --insecure-storage: the container has no keyring/D-Bus, so gh's default secure storage fails after the device-flow grant; the token persists as a file in the gh-config volume. got %v", args)
84+
}
85+
7686
func TestRunExitsCleanlyOnStartError(t *testing.T) {
7787
t.Setenv("PATH", t.TempDir())
7888
ctx, cancel := context.WithCancel(context.Background())

0 commit comments

Comments
 (0)