Documentation ¶
Overview ¶
Package authn implements the logic for authentication with OCI registries.
Index ¶
- Constants
- Variables
- func EmptyCredentialFunc(context.Context, string) (auth.Credential, error)
- func GCPCredential(ctx context.Context, reg string) (auth.Credential, error)
- func NewClient(options ...func(*Options)) *auth.Client
- func WithAutoLogin(handler *AutoLoginHandler) func(c *Options)
- func WithClientTokenCache(cache auth.Cache) func(c *Options)
- func WithCredentials(cred *auth.Credential) func(c *Options)
- func WithGcpCredentials() func(c *Options)
- func WithOAuthCredentials() func(c *Options)
- func WithStore(store credentials.Store) func(c *Options)
- type AutoLoginHandler
- type OAuthClientCredentialsStore
- type Options
Constants ¶
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 ¶
var ( // SavedTokenSource saved for all registries using gcp credentials. SavedTokenSource oauth2.TokenSource )
Functions ¶
func EmptyCredentialFunc ¶ added in v0.6.0
EmptyCredentialFunc provides empty auth credentials.
func GCPCredential ¶ added in v0.6.0
GCPCredential retrieves a valid access token from gcp source to perform registry authentication.
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
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.
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
func (o *OAuthClientCredentialsStore) Credential(ctx context.Context, reg string) (auth.Credential, error)
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.