Documentation
¶
Overview ¶
Package githubauth owns every GitHub credential used by gh-broker. Credentials are opaque outside this package and have no readback API.
Index ¶
- Constants
- Variables
- func IsNotFound(err error) bool
- func OpenUserCredentialStore(stateDir string) (*credentialstore.Store, error)
- func StatusCode(err error) (int, bool)
- func UserCredentialStorePath(stateDir string) (string, error)
- type API
- type APIError
- type Config
- type Credential
- type ExecutionResult
- type Kind
- type Manager
- func (m *Manager) API(credential *Credential) (*API, error)
- func (m *Manager) CheckApp(ctx context.Context) error
- func (m *Manager) CredentialKind() Kind
- func (m *Manager) EnableInstallation(installationID int64)
- func (m *Manager) EnrollUser(ctx context.Context, enrollment UserEnrollment) error
- func (m *Manager) ExecuteGraphQL(ctx context.Context, selector Metadata, document graphqlmanifest.Document, ...) (ExecutionResult, error)
- func (m *Manager) ExecuteREST(ctx context.Context, selector Metadata, binding opbinding.Binding, ...) (ExecutionResult, error)
- func (m *Manager) ExecuteRESTDownload(ctx context.Context, selector Metadata, binding opbinding.Binding, ...) (*http.Response, error)
- func (m *Manager) ExecuteRESTRaw(ctx context.Context, selector Metadata, binding opbinding.Binding, ...) (ExecutionResult, error)
- func (m *Manager) ExecuteRESTUpload(ctx context.Context, selector Metadata, binding opbinding.Binding, ...) (ExecutionResult, error)
- func (m *Manager) InstallationCredential(ctx context.Context, installationID int64, repositoryIDs []int64, ...) (*Credential, error)
- func (m *Manager) InstallationForAccount(ctx context.Context, account string) (Metadata, error)
- func (m *Manager) Installations(ctx context.Context) ([]int64, error)
- func (m *Manager) InvalidateInstallation(installationID int64, disabled bool)
- func (m *Manager) InvalidateUser(userID int64) error
- func (m *Manager) RepositoryCredential(ctx context.Context, operation, owner, repo string) (*Credential, error)
- func (m *Manager) ResolveRepository(ctx context.Context, operation, owner, repo string) (Metadata, error)
- func (m *Manager) RevokeUser(ctx context.Context, userID int64) error
- func (m *Manager) RotateUser(ctx context.Context, enrollment UserEnrollment) error
- func (m *Manager) SelectMetadata(ctx context.Context, descriptor opcatalog.Descriptor, target map[string]any, ...) (Metadata, error)
- func (m *Manager) UserCredential(ctx context.Context, userID int64) (*Credential, error)
- func (m *Manager) ValidateAuthenticatedUserTarget(ctx context.Context, selector Metadata, target map[string]any) error
- type Metadata
- type UserEnrollment
- type WebhookEvent
Constants ¶
const APIVersion = "2026-03-10"
Variables ¶
var ( ErrWebhookInvalid = errors.New("GitHub webhook is invalid") ErrWebhookSignature = errors.New("GitHub webhook signature is invalid") )
Functions ¶
func IsNotFound ¶
func OpenUserCredentialStore ¶
func OpenUserCredentialStore(stateDir string) (*credentialstore.Store, error)
OpenUserCredentialStore opens the broker-owned namespace reserved for internal GitHub App user credentials.
func StatusCode ¶
func UserCredentialStorePath ¶
UserCredentialStorePath returns the state subtree whose ownership the local setup command must preserve for the broker service account.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) BranchProtected ¶
type Config ¶
type Config struct {
AppID string
AppPrivateKey []byte
AppClientID string
AppClientSecret []byte
DevelopmentToken []byte
DevelopmentTokenFile string
APIBaseURL *url.URL
WebBaseURL *url.URL
HTTPClient *http.Client
StreamTimeout time.Duration
Store *credentialstore.Store
Now func() time.Time
RefreshBefore time.Duration
}
type Credential ¶
type Credential struct {
// contains filtered or unexported fields
}
Credential can authorize an upstream request without exposing its value.
func (*Credential) AuthorizeAPI ¶
func (c *Credential) AuthorizeAPI(request *http.Request) error
func (*Credential) AuthorizeGit ¶
func (c *Credential) AuthorizeGit(request *http.Request) error
func (*Credential) Metadata ¶
func (c *Credential) Metadata() Metadata
type ExecutionResult ¶
type ExecutionResult struct {
StatusCode int
Body json.RawMessage
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) CredentialKind ¶
func (*Manager) EnableInstallation ¶
func (*Manager) EnrollUser ¶
func (m *Manager) EnrollUser(ctx context.Context, enrollment UserEnrollment) error
func (*Manager) ExecuteGraphQL ¶
func (m *Manager) ExecuteGraphQL(ctx context.Context, selector Metadata, document graphqlmanifest.Document, variables map[string]any) (ExecutionResult, error)
func (*Manager) ExecuteREST ¶
func (*Manager) ExecuteRESTDownload ¶
func (*Manager) ExecuteRESTRaw ¶
func (m *Manager) ExecuteRESTRaw(ctx context.Context, selector Metadata, binding opbinding.Binding, target, arguments map[string]any) (ExecutionResult, error)
ExecuteRESTRaw returns one bounded upstream JSON result before projection. It is reserved for adapters that immediately move a credential field into an encrypted broker-owned slot.
func (*Manager) ExecuteRESTUpload ¶
func (*Manager) InstallationCredential ¶
func (*Manager) InstallationForAccount ¶
func (*Manager) Installations ¶
func (*Manager) InvalidateInstallation ¶
func (*Manager) InvalidateUser ¶
func (*Manager) RepositoryCredential ¶
func (*Manager) ResolveRepository ¶
func (*Manager) RotateUser ¶
func (m *Manager) RotateUser(ctx context.Context, enrollment UserEnrollment) error
func (*Manager) SelectMetadata ¶
func (*Manager) UserCredential ¶
type UserEnrollment ¶
type UserEnrollment struct {
UserID int64 `json:"user_id"`
Login string `json:"login"`
AccessToken []byte `json:"access_token"`
RefreshToken []byte `json:"refresh_token"`
AccessExpiresAt time.Time `json:"access_expires_at"`
RefreshExpiresAt time.Time `json:"refresh_expires_at"`
}
func DecodeUserEnrollment ¶
func DecodeUserEnrollment(data []byte) (UserEnrollment, error)
DecodeUserEnrollment decodes a bounded protected-file payload for the local setup command. Secret values are retained only in the returned byte slices.