Documentation ¶
Index ¶
Constants ¶
const ExpirationTime = time.Minute * 15
ExpirationTime jwt token expiration time
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 ¶
var ErrAuthPending = errors.New("auth pending")
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 ¶
BlockingCLIAuthHandler takes over the terminal experience and returns a token when the user completes the flow.
func NewAuthCLIHandler ¶
func NewAuthCLIHandler(name gitproviders.GitProviderName) (BlockingCLIAuthHandler, error)
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 ¶
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