githubapp

package
v1.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package githubapp provides repository-scoped GitHub App authentication.

Plane: shared

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOwnerNotAllowed marks a repository owner outside the daemon allowlist.
	ErrOwnerNotAllowed = errors.New("GitHub owner is not allowed")
	// ErrInstallationNotFound marks a repository without an accessible App installation.
	ErrInstallationNotFound = errors.New("GitHub App installation was not found")
)

Functions

This section is empty.

Types

type BrokerOption

type BrokerOption func(*brokerOptions)

BrokerOption configures internal broker dependencies.

func WithAPIBaseURL

func WithAPIBaseURL(baseURL string) BrokerOption

WithAPIBaseURL overrides GitHub's API URL for tests.

func WithHTTPTransport

func WithHTTPTransport(transport http.RoundTripper) BrokerOption

WithHTTPTransport overrides the GitHub HTTP transport for tests.

type Config

type Config struct {
	AppID         int64    `toml:"app_id"`
	KeySource     string   `toml:"key_source"`
	KeyRef        string   `toml:"key_ref"`
	AllowedOwners []string `toml:"allowed_owners"`
}

Config is the validated GitHub App section of og.toml.

func (Config) RequireOwner

func (c Config) RequireOwner(owner string) error

RequireOwner rejects repositories outside the configured owner allowlist.

func (*Config) Validate

func (c *Config) Validate() error

Validate normalizes and validates a GitHub App configuration section.

type CredentialBroker

type CredentialBroker interface {
	Token(ctx context.Context, owner, repo string, purpose Purpose) (string, error)
	Status(ctx context.Context, owner, repo string) (InstallationStatus, error)
	Invalidate(owner, repo string, purpose Purpose, failedToken string) error
}

CredentialBroker provides repository- and purpose-scoped App credentials.

func NewBroker

func NewBroker(cfg Config, keySource KeySource, options ...BrokerOption) (CredentialBroker, error)

NewBroker builds a broker and validates the configured App private key.

type InstallationStatus

type InstallationStatus struct {
	AppID          int64
	InstallationID int64
	Repository     string
	Permissions    map[string]string
}

InstallationStatus is non-secret installation metadata for one repository.

type KeySource

type KeySource interface {
	PrivateKey() (*rsa.PrivateKey, error)
}

KeySource loads the App's private key without exposing its storage details.

func NewKeySource

func NewKeySource(cfg Config, configDir string) (KeySource, error)

NewKeySource constructs the configured private-key source.

type Purpose

type Purpose string

Purpose identifies the minimum permission set needed by an operation.

const (
	PurposeAPI      Purpose = "pr-api"
	PurposeGitRead  Purpose = "git-read"
	PurposeGitWrite Purpose = "git-write"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL