Documentation
¶
Overview ¶
Package jwt implements the OAuth 2.0 JSON Web Token flow, commonly known as "two-legged OAuth 2.0". It has been modified to specifically support GitHub App JWT responses.
See: https://tools.ietf.org/html/draft-ietf-oauth-jwt-bearer-12 See: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#create-an-installation-access-token-for-an-app
Package jwt implements GitHub JWT authentication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
JWT
// Repositories is the list of repositories to limit the token access to.
Repositories struct {
// Names is the list of repository Names.
Names []string `json:"repositories,omitempty"`
// IDs is the list of repository IDs.
IDs []string `json:"repository_ids,omitempty"`
}
// TokenURL is the GitHub App Installation URL for creating access tokens.
// See: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#create-an-installation-access-token-for-an-app
TokenURL string
}
Config is the configuration for using GitHub JWT to fetch tokens.
func (*Config) Client ¶
Client returns an HTTP client wrapping the context's HTTP transport and adding Authorization headers with tokens obtained from c.
The returned client and its Transport should not be modified.
func (*Config) TokenSource ¶
func (c *Config) TokenSource(ctx context.Context) oauth2.TokenSource
TokenSource returns a JWT TokenSource using the configuration in c and the HTTP client from the provided context.
type JWT ¶
type JWT struct {
// AppID is the GitHub app ID.
AppID string
// PrivateKey contains the contents of an RSA private key or the
// contents of a PEM file that contains a private key. The provided
// private key is used to sign JWT payloads.
// PEM containers with a passphrase are not supported.
// Use the following command to convert a PKCS 12 file into a PEM.
//
// $ openssl pkcs12 -in key.p12 -out key.pem -nodes
//
PrivateKey *rsa.PrivateKey
// Expires optionally specifies how long the token is valid for.
Expires time.Duration
}
JWT is the base structure for GitHub JWT.