authn

package
v0.7.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Overview

Package authn implements the logic for authentication with OCI registries.

Index

Constants

View Source
const (
	// UsernameAccessToken is the valid username for Artifact Registry authentication with an access token
	// See https://cloud.google.com/artifact-registry/docs/docker/authentication#token
	UsernameAccessToken = "oauth2accesstoken"
)

Variables

View Source
var (
	// SavedTokenSource saved for all registries using gcp credentials.
	SavedTokenSource oauth2.TokenSource
)

Functions

func EmptyCredentialFunc added in v0.6.0

func EmptyCredentialFunc(context.Context, string) (auth.Credential, error)

EmptyCredentialFunc provides empty auth credentials.

func GCPCredential added in v0.6.0

func GCPCredential(ctx context.Context, reg string) (auth.Credential, error)

GCPCredential retrieves a valid access token from gcp source to perform registry authentication.

func NewClient

func NewClient(options ...func(*Options)) *auth.Client

NewClient creates a new authenticated client to interact with a remote registry.

func WithAutoLogin added in v0.6.0

func WithAutoLogin(handler *AutoLoginHandler) func(c *Options)

WithAutoLogin enables the clients auto login feature.

func WithClientTokenCache added in v0.6.2

func WithClientTokenCache(cache auth.Cache) func(c *Options)

WithClientTokenCache adds a cache to the auth.Client used to store auth tokens.

func WithCredentials

func WithCredentials(cred *auth.Credential) func(c *Options)

WithCredentials adds a static credential function to the client.

func WithGcpCredentials added in v0.6.0

func WithGcpCredentials() func(c *Options)

WithGcpCredentials adds the gcp source to the client.

func WithOAuthCredentials added in v0.6.0

func WithOAuthCredentials() func(c *Options)

WithOAuthCredentials adds the oauth credential store as credential source to the client.

func WithStore added in v0.6.0

func WithStore(store credentials.Store) func(c *Options)

WithStore adds the basic auth credential store as credential source to the client.

Types

type AutoLoginHandler added in v0.6.0

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

AutoLoginHandler performs registry logins automatically exactly once.

func NewAutoLoginHandler added in v0.6.0

func NewAutoLoginHandler(credStore credentials.Store) *AutoLoginHandler

NewAutoLoginHandler creates a new AutoLoginHandler.

func (*AutoLoginHandler) Login added in v0.6.0

func (a *AutoLoginHandler) Login(ctx context.Context, reg string) error

Login logs into the specified registry and stores the credentials in a local store.

type OAuthClientCredentialsStore added in v0.6.0

type OAuthClientCredentialsStore struct {
	OAuth2TokenSources map[string]oauth2.TokenSource
}

OAuthClientCredentialsStore provides credential retrieval for oauth client credentials.

func NewOauthClientCredentialsStore added in v0.6.0

func NewOauthClientCredentialsStore() OAuthClientCredentialsStore

NewOauthClientCredentialsStore creates a new OAuth client credential store.

func (*OAuthClientCredentialsStore) Credential added in v0.6.0

Credential retrieves a valid access token auth credential for the given registry.

type Options

type Options struct {
	Ctx                   context.Context
	CredentialsFuncsCache map[string]func(context.Context, string) (auth.Credential, error)
	CredentialsFuncs      []func(context.Context, string) (auth.Credential, error)
	AutoLoginHandler      *AutoLoginHandler
	ClientTokenCache      auth.Cache
}

Options used for the HTTP client that can authenticate with auth.Credentials or via OAuth2.0 Options Credentials flow.

Jump to

Keyboard shortcuts

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