Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidChallenge indicates an issue with the received challenge in the WWW-Authenticate header ErrInvalidChallenge = errors.New("Invalid challenge header") // ErrNoNewChallenge indicates a challenge update did not result in any change ErrNoNewChallenge = errors.New("No new challenge") // ErrNotFound indicates no credentials found for basic auth ErrNotFound = errors.New("No credentials available for basic auth") // ErrNotImplemented returned when method has not been implemented yet ErrNotImplemented = errors.New("Not implemented") // ErrParseFailure indicates the WWW-Authenticate header could not be parsed ErrParseFailure = errors.New("Parse failure") ErrUnauthorized = errors.New("Unauthorized") // ErrUnsupported indicates the request was unsupported ErrUnsupported = errors.New("Unsupported") )
Functions ¶
func DefaultCredsFn ¶
DefaultCredsFn is used to return no credentials when auth is not configured with a CredsFn This avoids the need to check for nil pointers
Types ¶
type BasicHandler ¶
type BasicHandler struct {
// contains filtered or unexported fields
}
BasicHandler supports Basic auth type requests
func (*BasicHandler) GenerateAuth ¶
func (b *BasicHandler) GenerateAuth() (string, error)
GenerateAuth for BasicHandler generates base64 encoded user/pass for a host
func (*BasicHandler) ProcessChallenge ¶
func (b *BasicHandler) ProcessChallenge(c Challenge) error
ProcessChallenge for BasicHandler is a noop
type BearerHandler ¶
type BearerHandler struct {
// contains filtered or unexported fields
}
BearerHandler supports Bearer auth type requests
func (*BearerHandler) GenerateAuth ¶
func (b *BearerHandler) GenerateAuth() (string, error)
GenerateAuth for BasicHandler generates base64 encoded user/pass for a host
func (*BearerHandler) ProcessChallenge ¶
func (b *BearerHandler) ProcessChallenge(c Challenge) error
ProcessChallenge for BasicHandler is a noop Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:samalba/my-app:pull,push"
type BearerToken ¶
type BearerToken struct {
Token string `json:"token"`
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
IssuedAt time.Time `json:"issued_at"`
RefreshToken string `json:"refresh_token"`
Scope string `json:"scope"`
}
BearerToken is the json response to the Bearer request
type Challenge ¶
type Challenge struct {
// contains filtered or unexported fields
}
Challenge is the extracted contents of the WWW-Authenticate header
func ParseAuthHeader ¶
ParseAuthHeader parses a single header line for WWW-Authenticate Example values: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:samalba/my-app:pull,push" Basic realm="GitHub Package Registry"
func ParseAuthHeaders ¶
ParseAuthHeaders extracts the scheme and realm from WWW-Authenticate headers
type CredsFn ¶
CredsFn is passed to lookup credentials for a given hostname, response is a username and password or empty strings
type Handler ¶
Handler handles a challenge for a host to return an auth header
func NewBasicHandler ¶
NewBasicHandler creates a new BasicHandler
type HandlerBuild ¶
HandlerBuild is used to make a new handler for a specific authType and URL
type Opts ¶
type Opts func(*auth)
Opts configures options for NewAuth
func WithDefaultHandlers ¶
func WithDefaultHandlers() Opts
WithDefaultHandlers includes a Basic and Bearer handler, this is automatically added with "WithHandler" is not called
func WithHTTPClient ¶
WithHTTPClient uses a specific http client with requests
func WithHandler ¶
func WithHandler(authType string, hb HandlerBuild) Opts
WithHandler includes a handler for a specific auth type