You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(auth): isolate GitHub App auth to stdio startup
Keep PEM loading and installation-token provider construction at the CLI leaf, then pass a generic refreshing token provider through the existing HTTP transports. Rebase the feature onto current main and keep the HTTP command unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 646357dd-c89f-4973-9a5c-e6c5fc18818c
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -311,7 +311,7 @@ Add one of the following JSON blocks to your IDE's MCP settings.
311
311
312
312
See **[Local Server OAuth Login](docs/oauth-login.md)** for the native-binary flow (no fixed port needed), the headless/device-code fallback, GitHub Enterprise Server / `ghe.com`, and bringing your own OAuth or GitHub App.
313
313
314
-
**Running headless (CI, Kubernetes, background agents)?** The stdio server can authenticate as a **GitHub App installation** with no browser, device code, or elicitation — see **[GitHub App Server-to-Server Authentication](docs/github-app-auth.md)**. This injects a high-privilege credential alongside the agent, so read the security guidance there first; it is not recommended without an independent security review.
314
+
For non-interactive stdio deployments, see **[GitHub App Authentication](docs/github-app-auth.md)**.
315
315
316
316
**Or authenticate with a Personal Access Token.** Set `GITHUB_PERSONAL_ACCESS_TOKEN` instead (it takes precedence over OAuth):
returnerrors.New("authentication required: set GITHUB_PERSONAL_ACCESS_TOKEN, configure GitHub App auth (GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID and GITHUB_APP_PRIVATE_KEY_PATH), or pass --oauth-client-id to log in via OAuth")
63
+
returnerrors.New("authentication required: set GITHUB_PERSONAL_ACCESS_TOKEN, configure GitHub App auth, or pass --oauth-client-id to log in via OAuth")
70
64
}
71
65
ifappAuthRequested&&token!="" {
72
66
returnerrors.New("GitHub App authentication and GITHUB_PERSONAL_ACCESS_TOKEN are mutually exclusive: set only one")
@@ -137,7 +131,6 @@ var (
137
131
// client. The requested scopes default to the full supported set
138
132
// (which filters out no tools); an explicit, narrower --oauth-scopes
139
133
// both narrows the grant and hides tools needing other scopes.
140
-
// Skipped for GitHub App auth, which sources tokens non-interactively.
141
134
iftoken==""&&!appAuthRequested {
142
135
scopes:=ghoauth.SupportedScopes
143
136
ifviper.IsSet("oauth-scopes") {
@@ -156,15 +149,12 @@ var (
156
149
stdioServerConfig.OAuthScopes=scopes
157
150
}
158
151
159
-
// GitHub App server-to-server auth: load and parse the private key,
160
-
// then resolve the REST base URL so the server can mint installation
161
-
// tokens for the configured host (github.com, GHES, or ghe.com).
stdioCmd.Flags().StringSlice("oauth-scopes", nil, "Comma-separated OAuth scopes to request; also filters tools to those scopes. Defaults to the full supported set")
264
254
stdioCmd.Flags().Int("oauth-callback-port", 0, "Fixed local port for the OAuth callback server. Defaults to a random port; set a fixed port when mapping it through Docker")
265
255
266
-
// stdio-specific GitHub App (server-to-server) flags. Provide an app ID,
267
-
// installation ID, and private key to authenticate non-interactively — no
268
-
// browser, device code, or elicitation. Intended for headless deployments.
269
-
// The private key itself has no flag (only GITHUB_APP_PRIVATE_KEY): a flag
270
-
// would place the key in the process arguments. Prefer the key file path.
256
+
// The private key has no flag because passing it in argv would expose it.
271
257
stdioCmd.Flags().String("app-id", "", "GitHub App ID or client ID, enabling non-interactive server-to-server authentication")
272
258
stdioCmd.Flags().String("app-installation-id", "", "GitHub App installation ID to mint installation access tokens for")
273
259
stdioCmd.Flags().String("app-private-key-path", "", "Path to the GitHub App private key (PEM). Preferred over GITHUB_APP_PRIVATE_KEY: keeps the key off the command line and out of the environment")
@@ -326,19 +312,11 @@ func main() {
326
312
}
327
313
}
328
314
329
-
// buildAppAuthConfig assembles the GitHub App server-to-server configuration:
330
-
// it loads and parses the private key and resolves the REST base URL for the
331
-
// configured host. The private key is read from a file (preferred) or an inline
332
-
// environment value; a missing or partial configuration yields a clear error.
0 commit comments