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.
C1: system context
Section titled “C1: system context”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
Text version of this diagram
System context relationships
- Developer or CI jobsends toRuns git and gh commands.Git and GitHub CLI
- Git and GitHub CLIsends toGit runs the credential helper per request; gh runs the extension. (local process, stdin and stdout)gh-app-auth
- 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)
- 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)
- 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
- Developer or CI jobsends toRuns git and gh commands.Git and GitHub CLI
- Git and GitHub CLIsends toGit runs the credential helper per request; gh runs the extension. (local process, stdin and stdout)gh-app-auth
- 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)
- 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)
- 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.
C2: containers (relationship view)
Section titled “C2: containers (relationship view)”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
- gh-app-auth processsends toReads patterns, priorities and key locations; setup, remove and migrate write it. (file)Configuration file (config.yml)
- gh-app-auth processsends toReads and writes private keys and PATs. (keyring API)OS keyring
- 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
- gh-app-auth processsends toExchanges a signed JWT for an installation token; refreshes installation scope. (HTTPS)GitHub API
- 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.
C3: core components (relationship view)
Section titled “C3: core components (relationship view)”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
- cmd (Cobra commands, git-credential)sends toLoads and validates configuration.pkg/config
- cmd (Cobra commands, git-credential)sends toSelects a GitHub App for a repository URL.pkg/matcher
- cmd (Cobra commands, git-credential)sends toObtains credentials for the selected App.pkg/auth
- cmd (Cobra commands, git-credential)sends toReads and refreshes cached installation scope.pkg/scope
- pkg/matcher and pkg/scopesends toRead App entries and scope metadata.pkg/config
- pkg/authsends toSigns the App JWT.pkg/jwt
- pkg/authsends toStores and reuses installation tokens in memory.pkg/cache
- pkg/auth and pkg/configsends toRead private keys and PATs from the keyring or files.pkg/secrets
Dynamic flow: Git requests credentials
Section titled “Dynamic flow: Git requests credentials”- Git matches the remote against its credential configuration and runs the helper with
get, passing--patternfor the matching context. - 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 --syncwritesuseHttpPathfor path-specific patterns, which is what makes Git send the repository path in the first place. - It loads the configuration and selects an App and any matching PATs; see how credential routing works.
- 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.
- It prints
usernameandpasswordto Git. For GitHub the username isx-access-token.
Dynamic flow: exec
Section titled “Dynamic flow: exec”execselects the credential from the repository or the explicit App selectors.- 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_HOSTandGH_REPO, then adds the token,GH_HOSTand, when a repository is known,GH_REPO. - It runs the child command and returns its exit status. The token is a snapshot: nothing renews it during the child’s run.
Not in the diagrams
Section titled “Not in the diagrams”- Package-level detail beyond the components above, which is in the source tree.
- The security model states exposure limits for each boundary.