Repository navigation
feat(appauth): narrow installation token permissions - #86
Merged
Merged
Conversation
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:d07b7831e61bd1b2;surface=exec
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.
Why
The reconciler design (#82, PR C of its split) limits the installation token to
metadataandpull_requestsread, as appendix B of the architecture docs requires. The request had no body, and GitHub issued the app's full permission set. This PR narrows the request. It must merge before PR G puts the reconciler into main.Behavior change
The token request now sends
{"permissions":{"metadata":"read","pull_requests":"read"}}with a JSON media type. The running service behaves as before, because no code calls the token source yet. Once PR G adds a caller, the token reads pull request data and nothing else.Decisions
The permissions body is a constant in
fetch. A response that grants fewer permissions than asked still counts as a valid token. The design is silent on that case, and GitHub documents that the response lists what it granted. The error rules, the https-only base URL, the 30 second timeout, the 2 hour expiry bound and the body cap don't change.Deviations from the task
The brief also had the run fix one paragraph of the design, section 4. It described
TokenandRenewas they were before the hardening in #80. The first run stopped on that mismatch. The paragraph now says thatTokenkeeps a still-valid cached token after a failed refresh and thatRenewreuses a token another caller fetched while it waited. The code didn't change.Needs human judgment
Nobody has verified here whether the installed app grants
pull_requestsread. GitHub answers a request for a permission the installation lacks with an error, and the source then returnsErrAuth. Someone with access to the app settings should confirm before PR G deploys.Risk
Medium, because this is credential code. The change touches only the request body and one header, and the tests check the exact body. The token source gets two review runs.
Verification
bazelisk test //internal/appauth/... //:vale_test //:rumdl_test //:cspell_test bazelisk run @tbhb_rules//lint:pr_size -- origin/main HEADThese pass, with
pr_size: code=31/400. The test server reads the request body and fails unless the body lists exactly the two read permissions. A Claude session read the full diff before opening the PR. A Codex run wrote the code.Human steering
None.
Opened-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli
Generated-by: LLM effort=high;harness=codex:0.171.0;model=openai:gpt-6.2-sol;session=sha-256-64:d07b7831e61bd1b2;surface=exec
Assisted-by: LLM effort=medium;harness=claude-code:2.1.330;model=anthropic:claude-sonnet-5-5;session=sha-256-64:6507fa80a17e0653;surface=cli