githubauth

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package githubauth provides interfaces and implementations for authenticating to GitHub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForAllRepos

func ForAllRepos() *allReposScope

ForAllRepos creates a scope that requests permissions on all repositories.

func ForRepos

func ForRepos(r ...string) *selectedReposScope

ForRepos creates a scope that requests permissions on the given repositories.

Types

type AppScope

type AppScope interface {
	*allReposScope | *selectedReposScope
}

AppScope is an interface which determines the repositories scope for which the app should request tokens.

type AppTokenSource

type AppTokenSource[T AppScope] struct {
	// contains filtered or unexported fields
}

AppTokenSource is a GitHubToken provider that authenticates as a GitHub App.

func NewAppTokenSource

func NewAppTokenSource[T AppScope](appID, installationID, privateKeyPEM string, scope T) (*AppTokenSource[T], error)

NewAppTokenSource returns a AppTokenSource which authenticates as a GitHub App and returns a GitHub token.

func (*AppTokenSource[T]) GitHubApp

func (s *AppTokenSource[T]) GitHubApp() *githubapp.GitHubApp

GitHubApp returns the underlying GitHubApp.

func (*AppTokenSource[T]) GitHubToken

func (s *AppTokenSource[T]) GitHubToken(ctx context.Context) (string, error)

GitHubToken implements TokenSource.

type StaticTokenSource

type StaticTokenSource struct {
	// contains filtered or unexported fields
}

StaticTokenSource is a GitHubToken provider that returns the provided token.

func NewStaticTokenSource

func NewStaticTokenSource(token string) (*StaticTokenSource, error)

NewStaticTokenSource returns a StaticTokenSource which returns the token string as given.

func (*StaticTokenSource) GitHubToken

func (s *StaticTokenSource) GitHubToken(ctx context.Context) (string, error)

GitHubToken implements TokenSource.

type TokenSource

type TokenSource interface {
	// GitHubToken returns a GitHub token, or any error that occurs.
	GitHubToken(ctx context.Context) (string, error)
}

TokenSource is an interface which returns a GitHub token.

Jump to

Keyboard shortcuts

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