auth

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ImpersonateServiceAccount = ""

easily impersonate a service account and maintain the TokenSource interface

Functions

func GetRootCmd

func GetRootCmd() *cobra.Command

func NewGoogleComputeTokenSourceWrapper added in v0.0.9

func NewGoogleComputeTokenSourceWrapper(ctx context.Context) (*tokenSourceWrapper, error)

func NewGoogleImpersonateTokenSourceWrapper added in v0.0.9

func NewGoogleImpersonateTokenSourceWrapper(ctx context.Context, email string, parentTs oauth2.TokenSource) (*tokenSourceWrapper, error)

func Token added in v0.0.5

func Token() (*oauth2.Token, error)

func TokenCtx added in v0.0.19

func TokenCtx(ctx context.Context) (*oauth2.Token, error)

Types

type ApplicationCredentialManager added in v0.0.12

type ApplicationCredentialManager struct {
	ClientID     string
	ClientSecret string
}

func DefaultApplicationCredentialManager added in v0.0.12

func DefaultApplicationCredentialManager() *ApplicationCredentialManager

func EnvApplicationCredentialManager added in v0.0.12

func EnvApplicationCredentialManager() *ApplicationCredentialManager

func (*ApplicationCredentialManager) AutoDetectLogin added in v0.0.12

func (m *ApplicationCredentialManager) AutoDetectLogin(ctx context.Context, quotaProject string) error

func (*ApplicationCredentialManager) BrowserFlowLogin added in v0.0.12

func (m *ApplicationCredentialManager) BrowserFlowLogin(ctx context.Context, quotaProject string) error

func (*ApplicationCredentialManager) CodeFlowLogin added in v0.0.12

func (m *ApplicationCredentialManager) CodeFlowLogin(ctx context.Context, quotaProject string) error

func (*ApplicationCredentialManager) ReadApplicationCredentials added in v0.0.12

func (m *ApplicationCredentialManager) ReadApplicationCredentials() (*ApplicationCredentials, error)

func (*ApplicationCredentialManager) WriteApplicationCredentials added in v0.0.12

func (m *ApplicationCredentialManager) WriteApplicationCredentials(ac *ApplicationCredentials) error

WriteApplicationCredentials idempotently writes out the application credentials to disk

type ApplicationCredentials added in v0.0.5

type ApplicationCredentials struct {
	ClientID       string `json:"client_id,omitempty"`
	ClientSecret   string `json:"client_secret,omitempty"`
	QuotaProjectId string `json:"quota_project_id,omitempty"`
	RefreshToken   string `json:"refresh_token,omitempty"`
	Type           string `json:"type,omitempty"`
	AuthUri        string `json:"auth_uri,omitempty"`
	TokenUri       string `json:"token_uri,omitempty"`

	// service account fields
	ProjectID               string `json:"project_id,omitempty"`
	PrivateKeyID            string `json:"private_key_id,omitempty"`
	PrivateKey              string `json:"private_key,omitempty"`
	ClientEmail             string `json:"client_email,omitempty"`
	AuthProviderX509CertUrl string `json:"auth_provider_x509_cert_url,omitempty"`
	ClientX509CertUrl       string `json:"client_x509_cert_url,omitempty"`
	// contains filtered or unexported fields
}

ApplicationCredentials is the a struct representing the application_default_credentials.json format. We add access_token and access_token_expiry for easy token caching and refresh.

func (*ApplicationCredentials) CacheKey added in v0.0.9

func (a *ApplicationCredentials) CacheKey() string

func (*ApplicationCredentials) SetContext added in v0.0.5

func (a *ApplicationCredentials) SetContext(ctx context.Context)

SetContext allows you to set the context on token refresh operations

func (*ApplicationCredentials) Token added in v0.0.5

func (a *ApplicationCredentials) Token() (*oauth2.Token, error)

Token ensures that we cache the access token. You should probably be using auth.Token() which conditionally calls this. This is slightly better than google.DefaultTokenSource because it has caching.

type CachingTokenSource added in v0.0.9

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

func IdentityTokenSource added in v0.0.12

func IdentityTokenSource(aud string) (*CachingTokenSource, error)

IdentityTokenSource gets a cached idtoken source. This can only be used with service accounts

func NewCachingTokenSource added in v0.0.9

func NewCachingTokenSource(ts TokenSourceWithCacheKey) (*CachingTokenSource, error)

func TokenSource

func TokenSource() (*CachingTokenSource, error)

TokenSource returns a cached application default credentials or falls back to the compute token source

func TokenSourceCtx added in v0.0.19

func TokenSourceCtx(ctx context.Context) (*CachingTokenSource, error)

func (*CachingTokenSource) GetAccessTokenPath added in v0.0.12

func (c *CachingTokenSource) GetAccessTokenPath() string

func (*CachingTokenSource) IdentityTokenSource added in v0.0.12

func (c *CachingTokenSource) IdentityTokenSource() *CachingTokenSource

IdentityTokenSource clones the current token source and configured the clone to return the identity token in the AccessToken field. this only works with user accounts.

func (*CachingTokenSource) Token added in v0.0.9

func (c *CachingTokenSource) Token() (*oauth2.Token, error)

type DockerHelperRes added in v0.0.5

type DockerHelperRes struct {
	Secret   string
	Username string
}

type TokenSourceWithCacheKey added in v0.0.9

type TokenSourceWithCacheKey interface {
	Token() (*oauth2.Token, error)
	CacheKey() string
}

Jump to

Keyboard shortcuts

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