Skip to content

Question: need to store credentials? #6

Description

@bwalsh

ADR 0002: Repository Access via GitHub App Installation Tokens

Status

Discussion

Context

The platform must read repository contents in order to:

  • clone repositories
  • inspect source code
  • validate pull requests
  • launch workflows
  • compute status checks
  • perform deployment automation

A design decision is required regarding how the platform authenticates to GitHub repositories.

Potential approaches include:

  1. User credentials (username/password)
  2. Personal Access Tokens (PATs)
  3. OAuth user tokens
  4. GitHub App installation tokens

The platform is intended to be multi-tenant and must minimize credential management, privilege escalation risk, and operational burden.


Decision

The platform SHALL access repositories using GitHub App installation access tokens.

The platform SHALL NOT require individual user credentials, personal access tokens, or OAuth user access tokens for normal repository operations.

Repository access will be granted by installing the GitHub App into an organization or repository.

The platform will:

  1. Generate a GitHub App JWT using the App private key.

  2. Exchange the JWT for an installation access token.

  3. Use the installation access token to:

    • read repository contents
    • clone repositories
    • access pull request metadata
    • create checks
    • update commit statuses
    • perform workflow-related GitHub API operations

The installation token represents the permissions granted to the GitHub App installation and is independent of any individual user account.


Rationale

GitHub Apps provide a server-to-server authentication model.

Repository access is authorized through the installation of the GitHub App rather than through an individual user's credentials.

This provides several advantages:

Security

  • No storage of user passwords.
  • No storage of personal access tokens.
  • Fine-grained repository permissions.
  • Short-lived installation tokens.
  • Independent credential rotation.

Multi-Tenancy

  • Installation tokens are scoped to a specific GitHub installation.
  • Different tenants may use different installations.
  • Access boundaries are enforced by GitHub.

Operational Simplicity

  • Users only install the App.
  • No user login flow required.
  • No token copy/paste workflow.
  • No PAT lifecycle management.

Auditability

GitHub records:

  • App installation events
  • Permission grants
  • App-generated actions

allowing administrators to audit platform access independently from user actions.


Consequences

Positive

  • No user credentials required.
  • No PAT management.
  • Least-privilege repository access.
  • Short-lived credentials.
  • Simplified onboarding.
  • Strong compatibility with multi-tenant architecture.

Negative

  • GitHub App must be installed before repository access is possible.
  • Additional implementation complexity around JWT generation and token exchange.
  • Installation token caching and renewal must be implemented.

Authentication Flow

sequenceDiagram
    participant Platform
    participant GitHub

    Platform->>GitHub: Create JWT signed with App private key
    GitHub-->>Platform: JWT accepted

    Platform->>GitHub: Request installation token
    GitHub-->>Platform: Installation Access Token

    Platform->>GitHub: Clone repository / call APIs
    GitHub-->>Platform: Repository data
Loading

Authorization Model

GitHub App
    │
    ├── Installation A
    │      ├── Repository 1
    │      └── Repository 2
    │
    └── Installation B
           ├── Repository 3
           └── Repository 4

The platform resolves:

(installation_id, repository_id)

to determine tenant ownership and authorization.


Alternatives Considered

Personal Access Tokens

Rejected because:

  • tied to individual users
  • difficult rotation lifecycle
  • excessive permissions
  • poor multi-tenant isolation

OAuth User Tokens

Rejected because:

  • requires user login flow
  • permissions tied to users
  • unsuitable for server-side automation

Shared Service Account

Rejected because:

  • difficult auditing
  • broad permissions
  • weak tenant isolation

References

GitHub documentation states that installation access tokens may be used for server-to-server API access and repository access, including cloning repositories over HTTPS.

Repository access is granted through App installation permissions and does not require individual user credentials.

Therefore, a properly configured GitHub App can read repository contents without requiring a user's GitHub username, password, personal access token, or OAuth credentials.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions