Documentation
¶
Overview ¶
Package oauth2 implements a generic configurable OAuth2 auth handler. Each CustomOAuth2Config registers as its own named auth.Handler supporting authorization code + PKCE, device code (RFC 8628), and client credentials (RFC 6749 §4.4).
Index ¶
- func ValidateConfig(cfg config.CustomOAuth2Config) error
- type Handler
- func (h *Handler) Capabilities() []auth.Capability
- func (h *Handler) DisplayName() string
- func (h *Handler) GetToken(ctx context.Context, opts auth.TokenOptions) (*auth.Token, error)
- func (h *Handler) InjectAuth(ctx context.Context, req *http.Request, opts auth.TokenOptions) error
- func (h *Handler) ListCachedTokens(ctx context.Context) ([]*auth.CachedTokenInfo, error)
- func (h *Handler) Login(ctx context.Context, opts auth.LoginOptions) (*auth.Result, error)
- func (h *Handler) Logout(ctx context.Context) error
- func (h *Handler) Name() string
- func (h *Handler) PurgeExpiredTokens(ctx context.Context) (int, error)
- func (h *Handler) RegistryUsername() string
- func (h *Handler) Status(ctx context.Context) (*auth.Status, error)
- func (h *Handler) SupportedFlows() []auth.Flow
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateConfig ¶
func ValidateConfig(cfg config.CustomOAuth2Config) error
ValidateConfig validates a CustomOAuth2Config for required fields and constraints.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements auth.Handler for generic configurable OAuth2 services.
func New ¶
func New(cfg config.CustomOAuth2Config, opts ...Option) (*Handler, error)
New creates a new generic OAuth2 auth handler from a CustomOAuth2Config.
func (*Handler) Capabilities ¶
func (h *Handler) Capabilities() []auth.Capability
Capabilities returns the handler's capabilities.
func (*Handler) DisplayName ¶
DisplayName returns the human-readable name.
func (*Handler) GetToken ¶
GetToken returns a valid access token, refreshing if necessary. If tokenExchange is configured, returns the derived token.
func (*Handler) InjectAuth ¶
InjectAuth adds an Authorization header to the HTTP request.
func (*Handler) ListCachedTokens ¶ added in v0.17.0
ListCachedTokens returns all cached tokens for this handler.
func (*Handler) PurgeExpiredTokens ¶ added in v0.17.0
PurgeExpiredTokens removes all expired access tokens from the cache.
func (*Handler) RegistryUsername ¶
RegistryUsername returns the configured OCI registry username convention for this handler (e.g. "$oauthtoken" for Quay.io). An empty string means the caller should use the default convention. This implements the optional catalog.RegistryUsernameProvider interface consumed by BridgeAuthToRegistry.
func (*Handler) SupportedFlows ¶
SupportedFlows returns the flows this handler supports based on config.
type Option ¶
type Option func(*Handler)
Option configures the Handler.
func WithHTTPClient ¶
WithHTTPClient sets a custom HTTP client.
func WithLogger ¶
WithLogger sets the logger for the handler.
func WithSecretKeyPrefix ¶ added in v0.17.0
WithSecretKeyPrefix overrides the default secret key prefix used for storing secrets in the keychain. This allows the generic oauth2.Handler to share tokens written by plugin auth handlers that use a different prefix convention.
func WithSecretStore ¶
WithSecretStore sets a custom secrets store.