Documentation

Overview

Package auth provides utilities for authentication, including generating and using App tokens and installation tokens. The package is based on the go- and golang.org/x/oauth2 libraries. It implements a set of TokenSource interfaces for generating App and installation tokens.

Index

Constants

View Source
const (
	// DefaultApplicationTokenExpiration is the default expiration time for the  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 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 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 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 WithContext added in v1.1.0

WithContext sets the context for the App installation token source.

func WithEnterpriseURLs added in v1.1.0

func WithEnterpriseURLs(baseURL, uploadURL string) InstallationTokenSourceOpt

WithEnterpriseURLs sets the base URL and upload URL for the App installation token source. This should passed after WithHTTPClient to ensure the HTTP client is updated with the new URLs. If the provided URLs are invalid, the default URLs are used.

func WithHTTPClient

func WithHTTPClient(client *http.Client) InstallationTokenSourceOpt

WithHTTPClient sets the HTTP client for the App installation token source.

func WithInstallationTokenOptions

func WithInstallationTokenOptions(opts *.InstallationTokenOptions) InstallationTokenSourceOpt

WithInstallationTokenOptions sets the options for the App installation token.

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