githubapp

package
v0.3.103-beta Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package githubapp checks a GitHub App registration live, so a typo never gets stored as this instance's login app.

Index

Constants

View Source
const DefaultAPIBase = "https://api.github.com"

DefaultAPIBase is api.github.com; GHE callers pass their own /api/v3 root.

Variables

This section is empty.

Functions

func ParsePrivateKey

func ParsePrivateKey(pemText string) (*rsa.PrivateKey, error)

ParsePrivateKey reads the .pem GitHub generates for an App: PKCS#1, or PKCS#8 holding an RSA key.

func SignJWT

func SignJWT(clientID string, key *rsa.PrivateKey, now time.Time) (string, error)

SignJWT signs the short-lived RS256 token GitHub accepts as the App itself; the client ID is the issuer.

func ValidateRepository

func ValidateRepository(owner, name string) error

ValidateRepository prevents URL normalization from changing the account whose installation is authorized.

func Verify

func Verify(ctx context.Context, hc *http.Client, apiBase, clientID, clientSecret, slug string) error

Verify confirms slug resolves to an app whose client_id is clientID, and that GitHub accepts clientSecret for it.

func VerifyCheck

func VerifyCheck(ctx context.Context, hc *http.Client, apiBase, check, clientID, clientSecret, slug string) error

VerifyCheck runs one named half of Verify ("slug" or "secret") so a setup form can tick each row on its own.

func VerifyKey

func VerifyKey(ctx context.Context, hc *http.Client, apiBase, clientID, pemText string) (err error)

VerifyKey confirms GitHub accepts a JWT signed with pemText as the App with clientID, through GET /app.

Types

type ManifestApp

type ManifestApp struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
	Slug         string `json:"slug"`
	PrivateKey   string `json:"pem"`
}

ManifestApp is the secret-bearing conversion result, kept server-side.

type ManifestClient

type ManifestClient struct {
	Client *http.Client
}

ManifestClient exchanges registration codes only with GitHub's API, without forwarding setup credentials.

func (ManifestClient) Convert

func (c ManifestClient) Convert(ctx context.Context, code string) (ManifestApp, error)

Jump to

Keyboard shortcuts

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