Documentation
¶
Overview ¶
Package githubapp checks a GitHub App registration live, so a typo never gets stored as this instance's login app.
Index ¶
- Constants
- func ParsePrivateKey(pemText string) (*rsa.PrivateKey, error)
- func SignJWT(clientID string, key *rsa.PrivateKey, now time.Time) (string, error)
- func ValidateRepository(owner, name string) error
- func Verify(ctx context.Context, hc *http.Client, ...) error
- func VerifyCheck(ctx context.Context, hc *http.Client, ...) error
- func VerifyKey(ctx context.Context, hc *http.Client, apiBase, clientID, pemText string) (err error)
- type ManifestApp
- type ManifestClient
Constants ¶
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 ¶
SignJWT signs the short-lived RS256 token GitHub accepts as the App itself; the client ID is the issuer.
func ValidateRepository ¶
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.
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 ¶
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)