Documentation
¶
Overview ¶
Package githubauth provides utilities for GitHub authentication, including generating and using GitHub App tokens and installation tokens. The package is based on the go-github and golang.org/x/oauth2 libraries. It implements a set of TokenSource interfaces for generating GitHub App and installation tokens.
Index ¶
- Constants
- func NewApplicationTokenSource(id int64, privateKey []byte, opts ...ApplicationTokenOpt) (oauth2.TokenSource, error)
- func NewInstallationTokenSource(id int64, src oauth2.TokenSource, opts ...InstallationTokenSourceOpt) oauth2.TokenSource
- type ApplicationTokenOpt
- type InstallationTokenSourceOpt
Constants ¶
const ( // DefaultApplicationTokenExpiration is the default expiration time for the GitHub App token. // The expiration time of the JWT, after which it can't be used to request an installation token. // The time must be no more than 10 minutes into the future. DefaultApplicationTokenExpiration = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func NewApplicationTokenSource ¶
func NewApplicationTokenSource(id int64, privateKey []byte, opts ...ApplicationTokenOpt) (oauth2.TokenSource, error)
NewApplicationTokenSource creates a new GitHub App token source using the provided application ID and private key. Functional options can be passed to customize the token source.
func NewInstallationTokenSource ¶
func NewInstallationTokenSource(id int64, src oauth2.TokenSource, opts ...InstallationTokenSourceOpt) oauth2.TokenSource
NewInstallationTokenSource creates a new GitHub App installation token source using the provided installation ID and token source. Functional options can be passed to customize the installation token source.
Types ¶
type ApplicationTokenOpt ¶
type ApplicationTokenOpt func(*applicationTokenSource)
ApplicationTokenOpt is a functional option for ApplicationTokenSource.
func WithApplicationTokenExpiration ¶
func WithApplicationTokenExpiration(expiration time.Duration) ApplicationTokenOpt
WithApplicationTokenExpiration sets the expiration for the GitHub App token. The expiration time of the JWT must be no more than 10 minutes into the future and greater than 0. If the provided expiration is invalid, the default expiration is used.
type InstallationTokenSourceOpt ¶
type InstallationTokenSourceOpt func(*installationTokenSource)
InstallationTokenSourceOpt is a functional option for InstallationTokenSource.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) InstallationTokenSourceOpt
WithHTTPClient sets the HTTP client for the GitHub App installation token source.
func WithInstallationTokenOptions ¶
func WithInstallationTokenOptions(opts *github.InstallationTokenOptions) InstallationTokenSourceOpt
WithInstallationTokenOptions sets the options for the GitHub App installation token.