Skip to content

Disable auth check for gh extension install#13176

Merged
williammartin merged 1 commit intotrunkfrom
kw/remove-ext-install-auth-check
Apr 16, 2026
Merged

Disable auth check for gh extension install#13176
williammartin merged 1 commit intotrunkfrom
kw/remove-ext-install-auth-check

Conversation

@BagToad
Copy link
Copy Markdown
Member

@BagToad BagToad commented Apr 15, 2026

Remove the authentication gate for gh extension install, allowing users to install extensions without being logged in.

Motivation

The global auth check blocks gh extension install from running at all when a user isn't authenticated. This is unnecessarily restrictive since installing extensions from public repositories or local directories doesn't inherently require authentication.

This is especially painful in Codespaces environments where SAML-scoped tokens trigger 403 errors when installing public extensions (#6675). Users currently have to unset GITHUB_TOKEN as a workaround.

Why this is OK

Look at what gh aw needs to do today to make extension installation reliable: https://github.com/github/gh-aw/blob/main/install-gh-aw.sh

What this says is that extension installation is going to happen unauthenticated whether we make it easier or not. We might as well make it easier and keep people installing through our core commands.

Related: #2680 (allow certain requests to be unauthenticated).

What this changes

Adds cmdutil.DisableAuthCheck to the extension install subcommand, bypassing the pre-execution login gate. This does not make unauthenticated API requests all the time. If a token is available it will still be used. It simply removes the requirement to be logged in before the command can run.

Allow installing extensions without being authenticated. The install
command can work with public repositories and local directories without
requiring a login, so the auth gate is unnecessary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BagToad BagToad requested a review from a team as a code owner April 15, 2026 23:59
@BagToad BagToad requested review from babakks and Copilot April 15, 2026 23:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the root-level authentication gate for gh extension install so extensions can be installed without being logged in (e.g., enabling unauthenticated installs when GITHUB_TOKEN is unset to avoid SAML-scoped token 403s).

Changes:

  • Disables the global auth check for the extension install subcommand via cmdutil.DisableAuthCheck(cmd).
Show a summary per file
File Description
pkg/cmd/extension/command.go Marks gh extension install to skip the root PersistentPreRunE auth requirement.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines 416 to +418
cmd.Flags().BoolVar(&forceFlag, "force", false, "Force upgrade extension, or ignore if latest already installed")
cmd.Flags().StringVar(&pinFlag, "pin", "", "Pin extension to a release tag or commit ref")
cmdutil.DisableAuthCheck(cmd)
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change alters root-level auth gating behavior for gh extension install, but there isn't a test that exercises the root PersistentPreRunE path to ensure the command runs when unauthenticated (no hosts and no env token). Consider adding a regression test (likely under pkg/cmd/root) that executes gh extension install … with a blank config and asserts it does not fail with AuthError / auth help output.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@williammartin williammartin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just copying something I wrote internally to here:

For me it's never been just as obvious as "is going to happen unauthenticated whether we make it easier or not". The core problem has always been that unauthenticated requests are limited to 60 req/hr per IP, and by supporting an easy path for extension installation like this we risk people rate limiting others.

In practice I have to imagine there are lots of people out there doing unauthenticated requests to the API via curl in Codespaces or Actions so like...maybe it's not a real issue. We've faffed around on this question for so long and it causes so much friction in some cases that we should just do it and see whether that ever actually becomes a real problem. Thanks for taking the initiative.

@williammartin williammartin merged commit ebe0631 into trunk Apr 16, 2026
43 checks passed
@williammartin williammartin deleted the kw/remove-ext-install-auth-check branch April 16, 2026 10:18
Copy link
Copy Markdown
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's do this! 🚀

@BagToad BagToad mentioned this pull request Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants