github

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyGitHubAuthClientConfig = GitHubAuthClientConfig{}
	EmptyGitHubAuthServerConfig = GitHubAuthServerConfig{}
)

Functions

func GitHubAuthHandlerFunc

func GitHubAuthHandlerFunc(cfg GitHubAuthServerConfig, next http.Handler) http.HandlerFunc

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 GitHubAuthClientConfig) (string, error)

func SaveAccessTokenToFile

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

Types

type Authenticator

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

func NewGitHubAuthenticator

func NewGitHubAuthenticator(cfg GitHubAuthServerConfig) *Authenticator

func (*Authenticator) AuthenticateToken

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

type GitHubAuthClientConfig

type GitHubAuthClientConfig struct {
	GitHubAuthCommonConfig           `mapstructure:",squash"`
	AccessToken                      string `mapstructure:"access-token"`
	AccessTokenFile                  string `mapstructure:"access-token-file"`
	EnableAccessTokenFromEnvironment bool   `mapstructure:"enable-access-token-from-environment"`
}

func (GitHubAuthClientConfig) IsEmpty

func (c GitHubAuthClientConfig) IsEmpty() bool

type GitHubAuthCommonConfig

type GitHubAuthCommonConfig 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 GitHubAuthHandler

type GitHubAuthHandler struct {
	Authenticator *Authenticator
	// contains filtered or unexported fields
}

func (GitHubAuthHandler) ServeHTTP

func (h GitHubAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GitHubAuthServerConfig

type GitHubAuthServerConfig struct {
	GitHubAuthCommonConfig `mapstructure:",squash"`

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

func (GitHubAuthServerConfig) IsEmpty

func (c GitHubAuthServerConfig) IsEmpty() bool

type GitHubClientAuth

type GitHubClientAuth struct {
	Config GitHubAuthClientConfig
	// contains filtered or unexported fields
}

func (GitHubClientAuth) AddAuth

func (a GitHubClientAuth) AddAuth(req *http.Request) 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