github

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadAccessTokenFromFile

func LoadAccessTokenFromFile(filePath string) (*api.AccessToken, error)

func NewContextWithGitHubUserInfo

func NewContextWithGitHubUserInfo(ctx context.Context, userInfo *UserInfo) context.Context

func ResolveAccessToken

func ResolveAccessToken(c ClientConfig) (string, error)

func SaveAccessTokenToFile

func SaveAccessTokenToFile(accessToken *api.AccessToken, authFilePath string) error

Types

type Authenticator

type Authenticator struct {
	Config ServerConfig
	Client *github.Client
}

func NewGitHubAuthenticator

func NewGitHubAuthenticator(cfg ServerConfig) *Authenticator

func (*Authenticator) AuthenticateToken

func (a *Authenticator) AuthenticateToken(accessToken string) (*UserInfo, error)

type ClientAuth added in v0.40.0

type ClientAuth struct {
	Config ClientConfig
	// contains filtered or unexported fields
}

func (ClientAuth) AddAuth added in v0.40.0

func (a ClientAuth) AddAuth(req *http.Request) error

func (ClientAuth) HTTPClient added in v0.40.0

func (a ClientAuth) HTTPClient() (*http.Client, error)

func (ClientAuth) Token added in v0.40.0

func (a ClientAuth) Token() (*oauth2.Token, error)

type ClientConfig added in v0.37.0

type ClientConfig struct {
	CommonConfig                     `mapstructure:",squash"`
	AccessToken                      string `mapstructure:"access-token"`
	AccessTokenFile                  string `mapstructure:"access-token-file"`
	EnableAccessTokenFromEnvironment bool   `mapstructure:"enable-access-token-from-environment"`
	EnvironmentVariableName          string `mapstructure:"environment-variable-name"`
}

type CommonConfig added in v0.37.0

type CommonConfig struct {
	AllowInsecureHTTP bool   `mapstructure:"allow-insecure-http"`
	ClientID          string `mapstructure:"client-id"`
	ClientSecret      string `mapstructure:"client-secret"`

	// ConfigFile containing ClientID and ClientSecret
	ConfigFile string `mapstructure:"config-file"`
}

only need ClientID for device flow

type Handler added in v0.37.0

type Handler struct {
	Authenticator *Authenticator
}

func NewHandler added in v0.37.0

func NewHandler(cfg ServerConfig) *Handler

func (*Handler) AuthRequest added in v0.37.0

func (h *Handler) AuthRequest(r *http.Request) (stdctx.Context, error)

func (*Handler) Wrap added in v0.37.0

func (h *Handler) Wrap(handler http.Handler) http.Handler

type ServerConfig added in v0.37.0

type ServerConfig struct {
	CommonConfig `mapstructure:",squash"`

	PrincipalACLConfig authz.PrincipalACLConfig `mapstructure:"principals"`
}

func FromMap added in v0.37.0

func FromMap(m map[string]interface{}) ServerConfig

type TokenRoundTripper added in v0.40.0

type TokenRoundTripper struct {
	Source oauth2.TokenSource
	Base   http.RoundTripper
}

func (*TokenRoundTripper) RoundTrip added in v0.40.0

func (t *TokenRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type TokenSource

type TokenSource struct {
	AccessToken string
}

func (*TokenSource) Token

func (t *TokenSource) Token() (*oauth2.Token, error)

type UserInfo

type UserInfo struct {
	Login                string
	Name                 string
	PrimaryEmail         string
	PrimaryEmailVerified bool
	Company              string
	WebSite              string
	Location             string
	PlanName             string
}

func FetchUserInfo

func FetchUserInfo(accessToken string) (*UserInfo, error)

func GitHubUserInfoFromContext

func GitHubUserInfoFromContext(ctx context.Context) *UserInfo

Jump to

Keyboard shortcuts

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