Skip to content

feat: find the installation by owner and request newer permissions - #88

Merged
jferrl merged 2 commits into
mainfrom
feat/permissions-and-owner
Oct 30, 2026
Merged

jferrl merged 2 commits into
mainfrom
feat/permissions-and-owner

Conversation

@jferrl

@jferrl jferrl commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

To mint a token, githubauth token needs the installation's numeric ID, which people usually don't know: they know the account the App is installed on. --owner acme now looks the ID up. Separately, GitHub added App permissions in October 2026 that InstallationPermissions has no field for, so library callers could not request them. A new Other field carries any permission by GitHub's name.

What this does

Invocation Before After
token --owner acme Not a flag Finds the installation on acme, then mints
token --owner acme --installation 9 Not a flag Exit 2: one or the other
token --owner acme where the App is not installed Not a flag Exit 5, hint names --owner
Library: Permissions: &InstallationPermissions{Other: {"installation_repositories": "write"}} Not possible Sent with the other permissions

Changes

  • --owner and FindInstallationID(ctx, appSrc, owner, opts...) call GET /users/{owner}/installation, which answers for organizations too.
  • InstallationPermissions.Other is sent alongside the fields. A name set both as a field and in Other fails before any request.
  • The 422 hint now mentions --permissions, and the 404 hint --owner.
  • The AGENTS.md scope rule now allows the lookups that minting or ending a token needs.

Rationale

--permissions in the CLI still accepts only names with a field. Whether GitHub refuses or ignores a name it does not know is untested, and ignoring it would mint a token with every permission the App has. A test with a real App decides when the CLI can send unknown names through Other.

go-github has Apps.FindUserInstallation. The lookup lives here anyway because it is part of getting a token, and it reuses the token request's Enterprise URL handling and redirect policy.

Migration Notes

Only additions to the API, so this fits in v1.12.0 with #87. Before that release, a real App should confirm three things: revocation of the new stateless tokens, GitHub's answer to an unknown permission name, and --owner for an organization.

githubauth token --owner acme looks the installation up, so a caller who
knows the account no longer needs its numeric ID. It uses the users
endpoint, which answers for organizations too, as
actions/create-github-app-token does. The lookup is a library function,
FindInstallationID, so it shares the Enterprise URL handling and the
redirect policy of the token request.

InstallationPermissions.Other carries a permission the struct has no
field for, such as installation_repositories, so a permission GitHub
adds can be requested before a field exists. The CLI still accepts only
the names with a field: whether GitHub refuses or ignores an unknown
name is untested, and ignoring it would widen the token.

AGENTS.md now allows the lookups that minting or ending a token needs.
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.74%. Comparing base (a8b1388) to head (722a228).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #88      +/-   ##
==========================================
+ Coverage   97.43%   97.74%   +0.30%     
==========================================
  Files           8        8              
  Lines         742      797      +55     
==========================================
+ Hits          723      779      +56     
+ Misses         19       18       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- FindInstallationID escapes the owner. JoinPath takes escaped elements,
  so a raw "%" left the JWT-authenticated GET at the API root, and an
  escaped slash added a path segment.
- SIGINT and SIGTERM are held from before the command starts until the
  token is revoked. A SIGTERM arriving during the revocation used to
  kill githubauth with the token still valid and the command's exit
  code lost.
- When githubauth itself fails, a failed revocation joins that failure
  instead of printing a warning, so under --agent stderr stays empty and
  the one JSON report says the token is still valid.
- --owner . and .. exit 2 rather than 1.
- The test command now uses its token, and the revoke tests check it did
  so before the revocation, not merely that a DELETE was sent.
@jferrl
jferrl merged commit b9b5c34 into main Oct 30, 2026
10 checks passed
@jferrl
jferrl deleted the feat/permissions-and-owner branch October 30, 2026 18:03
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.

1 participant