auth

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: MPL-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const ExpirationTime = time.Minute * 15

ExpirationTime jwt token expiration time

View Source
const WeGOGithubClientID = "edcb13588d46f254052c"

Uniquely identifies us as a GitHub app. This does not need to be obfuscated because it is publicly available to anyone who does an OAuth request via wego. See the auth ADR for more details: https://github.com/weaveworks/weave-gitops/blob/main/doc/adr/0005-wego-core-auth-strategy.md#design

Variables

View Source
var ErrAuthPending = errors.New("auth pending")
View Source
var ErrUnauthorizedToken = errors.New("unauthorized token")

ErrUnauthorizedToken unauthorized token error

Functions

func GetGitProvider

func GetGitProvider(ctx context.Context, url string) (gitproviders.GitProvider, error)

GetGitProvider returns a GitProvider containing either the token stored in the <git provider>_TOKEN env var or a token retrieved via the CLI auth flow

Types

type AuthService

type AuthService interface {
	CreateGitClient(ctx context.Context, repoUrl, targetName, namespace string) (git.Git, error)
	GetGitProvider() gitproviders.GitProvider
}

func NewAuthService

func NewAuthService(fluxClient flux.Flux, k8sClient client.Client, provider gitproviders.GitProvider, l logger.Logger) (AuthService, error)

NewAuthService constructs an auth service for doing git operations with an authenticated client.

type BlockingCLIAuthHandler

type BlockingCLIAuthHandler func(context.Context, io.Writer) (string, error)

BlockingCLIAuthHandler takes over the terminal experience and returns a token when the user completes the flow.

func NewGithubDeviceFlowHandler

func NewGithubDeviceFlowHandler(client *http.Client) BlockingCLIAuthHandler

NewGithubDeviceFlowHandler returns a function which will initiate the Github Device Flow for the CLI.

type Claims

type Claims struct {
	jwt.StandardClaims
	Provider      gitproviders.GitProviderName `json:"provider"`
	ProviderToken string                       `json:"provider_token"`
}

Claims is a custom JWT claims that contains some token information

type JWTClient

type JWTClient interface {
	GenerateJWT(expirationTime time.Duration, providerName gitproviders.GitProviderName, providerToken string) (string, error)
	VerifyJWT(accessToken string) (*Claims, error)
}

JWTClient represents a type that has methods to generate and verify JWT tokens.

func NewJwtClient

func NewJwtClient(secretKey string) JWTClient

NewJwtClient initialize JWTClient instance

type SecretName

type SecretName struct {
	Name      app.GeneratedSecretName
	Namespace string
}

func (SecretName) NamespacedName

func (sn SecretName) NamespacedName() types.NamespacedName

func (SecretName) String

func (sn SecretName) String() string

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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