DEV Community

Cover image for GitHub Apps Can Now Run Your Enterprise Admin Automation. Time to Retire That Classic PAT
Mango Developer
Mango Developer

Posted on Originally published at mangodeveloper.com

GitHub Apps Can Now Run Your Enterprise Admin Automation. Time to Retire That Classic PAT

Somewhere in your company there is a script that runs on a personal access token belonging to someone who left two years ago. It changes a policy, rotates a setting or syncs a list, and everyone is afraid to touch it. If you manage a GitHub enterprise, this week's announcement is a good excuse to fix that.

On October 23, GitHub declared enterprise installations for GitHub Apps generally available. The changelog says you can now replace classic personal access tokens, or PATs, with GitHub Apps in more of your enterprise and organization automation. I think this is one of the more useful changes for platform teams this month, with one important caveat I'll get to.

What changed

According to the GitHub changelog, the new and expanded permissions focus on governance, security and administration for the enterprise, and two gaps at the organization level are also closed. Here is how GitHub groups the additions:

  • Governance: manage enterprise-level repository policies and rulesets, and read delegated bypass requests.
  • Security: configure two-factor authentication requirements, verify domains, manage IP allowlists and control enterprise access restrictions.
  • Administration: update enterprise profiles and manage member privileges and repository access settings across the enterprise.

The detail is in the permission table. A few examples worth knowing:

Permission Access What apps can now do
Enterprise organization and repository policies Read/write Update private repository forking, default repository permissions, visibility changes, repository creation and deletion, issue deletion, collaborator invitations, deploy keys, protected branch updates and more
Enterprise bypass requests Read Read push-rule and repository-policy bypass requests
Enterprise two-factor authentication Read/write Read two-factor fields and update two-factor requirements and disallowed authentication methods
Enterprise and organization IP allowlist Read/write Create, update and delete allowlist entries, toggle enforcement and trust of GitHub Apps
Enterprise access restrictions Write Enable or disable enterprise access restrictions
Enterprise repository rulesets Write Manage rulesets through the company-wide rules REST APIs and in GraphQL

the company also lists gaps closed with existing permissions: apps with enterprise people access can read company-wide repository details, including outside collaborators, and add themselves to an organization as an owner or member, and an enterprise billing permission lets apps update the member purchasing setting for the Marketplace. the company says the updates will be available in GitHub Enterprise Server 3.24.

GitHub Apps installation page asking an company-wide admin to approve enterprise settings permissions

Expand

GitHub Apps installation page asking an company-wide admin to approve enterprise settings permissions

Image: GitHub Changelog

Why this is a big deal

A classic PAT is tied to a person. It carries that person's permissions, it breaks when they leave, and it tends to be far broader than the job needs. A GitHub App is a separate identity with permissions you pick one by one, installed where you choose.

Until now, many company-wide-level jobs, such as changing a policy, managing an allowlist or adjusting two-factor requirements, needed a PAT because apps lacked the API coverage. the changelog frames this release as the fix: more of that automation can move to apps.

This follows a related release on October 13, when GitHub said it was shipping several GitHub Apps improvements to help developers move off classic PATs. That post added two new repository permissions, repository_creation:write and installation_repositories:write, available to both fine-grained PATs and GitHub Apps, and made it easier for repository administrators to add approved apps. If you are planning a migration, read both posts together. Our guide on GitHub CLI's new expiring tokens covers a neighbouring change on the user-token side.

The caveat: a powerful app is a powerful identity

Breachroad makes the point I would stress. Moving from a PAT to a GitHub App improves attribution and scope control, but "the mechanism's name does not guarantee least privilege." An app that can change policies, two-factor requirements and IP allowlists is a privileged machine identity that needs oversight comparable to an administrator account.

That is the right frame. You are not removing power from automation, you are making it visible and scoped. Treat the app like a person with admin rights: review who can change its settings, who can see its private key, and where the key lives.

WindowsForum, in its coverage, also notes that earlier GitHub changelog posts describe one enterprise permission, the one that can manage app installations across every organization in an company-wide, as extremely powerful, and that apps requesting the "Enterprise organization installations" permission can only be installed on the enterprise that owns them. It also reports that GitHub's documentation page it reviewed still labelled company-wide-installed apps as public preview even though the changelog announced general availability. I have not verified that docs page myself, so check the current wording before you commit to a rollout plan.

A migration plan I'd actually follow

We haven't tested this feature ourselves. This is analysis of GitHub's changelog and the coverage cited above.

  1. Inventory your enterprise automation. List every script, workflow and integration that uses a classic PAT for company-wide or organization administration. Note who owns the token and what it actually calls.
  2. Pick the first target by risk. Start with automations that touch security settings, such as IP allowlists and two-factor requirements, since a leaked PAT there is the worst case.
  3. Map each call to the new permission. Use the permission table in the changelog and request only what the job needs. Start with read access where you can.
  4. Create the app and install it on the enterprise. Choose permissions in the GitHub App settings, as the changelog instructs.
  5. Run the old and new path side by side for a short period, compare results, then revoke the PAT.
  6. Store the app's private key in a secrets manager, rotate it on a schedule, and record who can access it.
  7. Add the app to your regular access review, the same way you review human admins.

If you run GitHub Enterprise Server, plan around version. the company lists these updates as available in GHES 3.24, so an older server will not have them.

GitHub logo displayed on a screen

Expand

GitHub logo displayed on a screen

Image: Justin Oh via Wikimedia Commons, CC0

What to watch out for

Do not give an app every permission just because the installation screen lets you. The point of this migration is to narrow what each automation can do.

Watch token behaviour too. Safeguard reports that GitHub's rollout of stateless installation tokens is complete and that new installation tokens are roughly 520 characters long instead of about 40, in a ghs_APPID_JWT format. If any of your tooling assumes a short token length, check it. Also note that GitHub's October 13 post mentions per-request opt-in for expiring tokens, per its community discussion, so read how that interacts with your app before enabling it.

Troubleshooting

If an API call fails with a permission error after you move to an app, the likeliest cause is a missing permission or a missing read prerequisite. GitHub's table notes that read access to company-wide settings is required for access to the enterprise organization and repository policies, so a write permission alone may not be enough. If an app cannot be installed on the company-wide, check whether it requests a permission that restricts installation to the owning enterprise. If a GraphQL query fails, check that it uses a field now supported for GitHub Apps, such as EnterpriseOwnerInfo.

Should you care?

If you administer a GitHub company-wide, yes, and sooner than later. The longer a critical script runs on a person's token, the more it behaves like a time bomb. If you only manage a single repository or a small organization, you can skip this; the practical benefit is at enterprise scale.

Frequently Asked Questions

What exactly became generally available?

Installing GitHub Apps on your company-wide, with expanded API support for enterprise and organization governance, security and administration.

Does it work on GitHub Enterprise Server?

the company says the updates will be available in GHES 3.24.

Can an app manage two-factor and IP allowlist settings?

Yes. the company lists company-wide two-factor and IP allowlist permissions with read and write access.

Is an app safer than a PAT?

Often, because of scope and attribution, but Breachroad warns that a powerful app is still a privileged machine identity that needs oversight.

Image: GitHub Changelog


Originally published on Mango Developer.

Top comments (0)