Skip to content

Architecture

This page follows the C4 model, from the outside in. The C1 diagram is a graph, with a full text version generated from the same data. The C2 and C3 views are relationship views: lists of directed relationships (“from, label, to”), not complete graphs.

Who uses gh-app-auth and what it talks to.

System context: gh-app-auth is one short-lived process per invocation, not a daemon

C1 system context of gh-app-authDevelopers and CI jobs run Git and the GitHub CLI. Git and the GitHub CLI call gh-app-auth as a local helper or extension. gh-app-auth exchanges a signed JWT for an installation token with GitHub over HTTPS, for App credentials only. Git and the GitHub CLI call GitHub over HTTPS with the credential returned or injected, and call other HTTPS Git hosts with a stored personal access token. A full text version follows the diagram.runs gitand ghlocal helperor extensionstdin, stdoutsigned JWT for aninstallation tokenApp only, HTTPSGit and gh calls with the credential (HTTPS)Git with a stored PAT (HTTPS, PAT only)Developer or CI jobGit and GitHub CLIgh-app-authGitHub.com / GHESOther HTTPS GithostsPerson or automationExternalgh-app-authLocal callNetwork (HTTPS)
Text version of this diagram

System context relationships

  1. Developer or CI jobsends toRuns git and gh commands.Git and GitHub CLI
  2. Git and GitHub CLIsends toGit runs the credential helper per request; gh runs the extension. (local process, stdin and stdout)gh-app-auth
  3. gh-app-authsends toFinds the installation and exchanges a signed JWT for a short-lived installation token. App credentials only. (HTTPS REST API)GitHub (github.com or Enterprise Server)
  4. Git and GitHub CLIsends toGit operations and API calls, authenticated with the credential that gh-app-auth returned or injected. (HTTPS)GitHub (github.com or Enterprise Server)
  5. Git and GitHub CLIsends toGit operations authenticated with a stored personal access token. No GitHub API is involved. (HTTPS, PAT only)Other HTTPS Git hosts

System context relationships

  1. Developer or CI jobsends toRuns git and gh commands.Git and GitHub CLI
  2. Git and GitHub CLIsends toGit runs the credential helper per request; gh runs the extension. (local process, stdin and stdout)gh-app-auth
  3. gh-app-authsends toFinds the installation and exchanges a signed JWT for a short-lived installation token. App credentials only. (HTTPS REST API)GitHub (github.com or Enterprise Server)
  4. Git and GitHub CLIsends toGit operations and API calls, authenticated with the credential that gh-app-auth returned or injected. (HTTPS)GitHub (github.com or Enterprise Server)
  5. Git and GitHub CLIsends toGit operations authenticated with a stored personal access token. No GitHub API is involved. (HTTPS, PAT only)Other HTTPS Git hosts

gh is a client of the GitHub API only. Other HTTPS Git hosts, such as Bitbucket, are reached by Git with a personal access token (PAT), never through the GitHub API.

gh-app-auth is a single Go binary. Git or gh starts a new process for each invocation, and the process exits when it is done. There is no daemon.

Containers

  1. gh-app-auth processsends toReads patterns, priorities and key locations; setup, remove and migrate write it. (file)Configuration file (config.yml)
  2. gh-app-auth processsends toReads and writes private keys and PATs. (keyring API)OS keyring
  3. gh-app-auth processsends toReads App private keys from plain files when the filesystem source is chosen. PAT reads from here are not implemented. (file)Secrets directory or key file
  4. gh-app-auth processsends toExchanges a signed JWT for an installation token; refreshes installation scope. (HTTPS)GitHub API
  5. gh-app-auth processsends toAppends flow events when GH_APP_AUTH_DEBUG_LOG is set. (file)Diagnostic log file

Installation tokens live in an in-memory cache inside the process: 55 minutes, never written to disk, and gone when the process exits. Because Git starts a fresh helper per request, the cache mainly helps processes that stay alive. A background worker removes expired entries; it does not renew them.

A selective view of the Go packages that matter for credential selection. Packages are code organization inside the one process, not separate deployable containers.

Core components

  1. cmd (Cobra commands, git-credential)sends toLoads and validates configuration.pkg/config
  2. cmd (Cobra commands, git-credential)sends toSelects a GitHub App for a repository URL.pkg/matcher
  3. cmd (Cobra commands, git-credential)sends toObtains credentials for the selected App.pkg/auth
  4. cmd (Cobra commands, git-credential)sends toReads and refreshes cached installation scope.pkg/scope
  5. pkg/matcher and pkg/scopesends toRead App entries and scope metadata.pkg/config
  6. pkg/authsends toSigns the App JWT.pkg/jwt
  7. pkg/authsends toStores and reuses installation tokens in memory.pkg/cache
  8. pkg/auth and pkg/configsends toRead private keys and PATs from the keyring or files.pkg/secrets
  1. Git matches the remote against its credential configuration and runs the helper with get, passing --pattern for the matching context.
  2. The helper reads the host, protocol and path Git sends. With no path it returns empty output. It does not rely on Git asking again: gitconfig --sync writes useHttpPath for path-specific patterns, which is what makes Git send the repository path in the first place.
  3. It loads the configuration and selects an App and any matching PATs; see how credential routing works.
  4. For an App it signs a JWT, finds or reuses the installation, and exchanges the JWT for an installation token, or reuses a cached token. For a PAT it reads the token from the keyring.
  5. It prints username and password to Git. For GitHub the username is x-access-token.
  1. exec selects the credential from the repository or the explicit App selectors.
  2. It mints an installation token (or reads the PAT) and builds a child environment from the current one: it removes the GitHub token variables, GH_HOST and GH_REPO, then adds the token, GH_HOST and, when a repository is known, GH_REPO.
  3. It runs the child command and returns its exit status. The token is a snapshot: nothing renews it during the child’s run.
  • Package-level detail beyond the components above, which is in the source tree.
  • The security model states exposure limits for each boundary.