Implement GitHub App authentication#2284
Conversation
|
Is there a general overview of what will be required? Some questions:
Can we add a little more detail to "How triagebot works" in the README? Something I have neglected to do is fill that out more1, and I don't want to get further behind. Just briefly explain that the production server runs as a GitHub App, and how the app is installed (org-wide?). And reiterate it doesn't have to run as an App and can run with a PAT. Footnotes
|
|
I'll answer all these, just wanted to wait for the discussion in https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/Triagebot.20GitHub.20App.20migration/with/573317366 to finish, because right now it's not 100% clear that we can even technically make the switch (though probably we should be able to). |
|
Looks like we should be able to use the app, though it will require some other infra work, so it will take some time. So the promised answers:
Yes, it needs to be managed by infra admins. That being said, we found out that we already have an existing
Both are possible. Since we already configure
We can add it very granular permissions, unlike the current
Locally it takes ~300-400ms, just a network request. The token lasts for an hour and it is cached by octocrab, so I wouldn't be worried about that.
None, really. Though comments will no longer be posted by the
Security is the main reason, yeah. We can assign fine-grained permissions to the app, rather than just using a catch-all write access (for example triagebot is now able to push to repositories that don't have branch protections scoped to specific users or teams). The token will also be short lived, which is in general better, and the account will clearly be marked as a bot. Also, PATs were deprecated by GitHub some time ago, and it seems harder and harder to use them, e.g. we now can't even see them in the GitHub UI on the enterprise level, IIRC. I'll let @marcoieni chime in, in case you want to add something.
The base rate limit should be the same as for PATs, so 5k reqs/hour (https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-github-app-installations). In fact, it can be even higher than for PATs (up to 12.5k or even 15k/hour).
It's infrastructure, so pretty much anything, really 😆 We should ensure that PATs still continue work for local experiments and debugging, but that should already be the case in this PR. That being said, the exact same approach is used in
Sure, I'll do that once we're sure that it is possible to use a GH app for triagebot. |
Yes, I believe that is true. I would guess that it should be able to write to private if it is added to the bot list, but none of them are. |
This means that the rustbot account will no longer be sending the triagebot comments, which can have... consequences 😆 Opening as a draft for now.