auth

package
v0.0.0-...-f30a32e Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxWithCreds

func CtxWithCreds(ctx context.Context) context.Context

CtxWithCreds returns a context with default credentials for the user. Since this uses MustLoadDefaultCredentials, a lack of credentials will cause an os.Exit

func IsAuthenticated

func IsAuthenticated(cloudAddr string) bool

IsAuthenticated returns whether the user is currently authenticated. This includes whether they have existing credentials and whether those are actually valid.

func SaveRefreshToken

func SaveRefreshToken(token *RefreshToken) error

SaveRefreshToken saves the refresh token in default spot.

Types

type PixieCloudLogin

type PixieCloudLogin struct {
	ManualMode bool
	CloudAddr  string
	// OrgID: Selection is only valid for "pixie.support", will be removed when RBAC is supported.
	OrgID string
	// UseAPIKey, if true then prompt user for API key to use for login.
	UseAPIKey bool
	// APIKey to use if specified. Otherwise, prompt for the key if UseAPIKey is true.
	APIKey string
}

PixieCloudLogin performs login on the pixie cloud.

func (*PixieCloudLogin) Run

func (p *PixieCloudLogin) Run() (*RefreshToken, error)

Run either launches the browser or prints out the URL for auth.

type RefreshToken

type RefreshToken struct {
	Token     string `json:"token"`
	ExpiresAt int64  `json:"expiresAt"`
	OrgName   string `json:"orgName,omitempty"`
	OrgID     string `json:"orgID,omitempty"`
}

RefreshToken is the format for the refresh token.

func LoadDefaultCredentials

func LoadDefaultCredentials() (*RefreshToken, error)

LoadDefaultCredentials loads the default credentials for the user.

func MustLoadDefaultCredentials

func MustLoadDefaultCredentials() *RefreshToken

MustLoadDefaultCredentials loads the default credentials for the user. An error will print to console and call os.Exit.

Jump to

Keyboard shortcuts

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