Documentation ¶
Index ¶
- func NewBasicAuthNoUsernameError() error
- type BasicAuthNoUsernameError
- type BasicChallengeHandler
- func (c *BasicChallengeHandler) CanHandle(headers http.Header) bool
- func (c *BasicChallengeHandler) CompleteChallenge(requestURL string, headers http.Header) error
- func (c *BasicChallengeHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)
- func (c *BasicChallengeHandler) Release() error
- type ChallengeHandler
- type MultiHandler
- func (h *MultiHandler) CanHandle(headers http.Header) bool
- func (h *MultiHandler) CompleteChallenge(requestURL string, headers http.Header) error
- func (h *MultiHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)
- func (h *MultiHandler) Handlers() []ChallengeHandler
- func (h *MultiHandler) Release() error
- type PasswordPrompter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBasicAuthNoUsernameError ¶
func NewBasicAuthNoUsernameError() error
NewBasicAuthNoUsernameError returns an error for a basic challenge without a username
Types ¶
type BasicAuthNoUsernameError ¶
type BasicAuthNoUsernameError struct{}
BasicAuthNoUsernameError when basic authentication challenge handling was attempted but the required username was not provided from the command line options
func (*BasicAuthNoUsernameError) Error ¶
func (e *BasicAuthNoUsernameError) Error() string
type BasicChallengeHandler ¶
type BasicChallengeHandler struct { // Host is the server being authenticated to. Used only for displaying messages when prompting for username/password Host string // WebConsoleURL is an optional URL to a web interface where the user might go if they prefer login from the browser instead WebConsoleURL string // Reader is used to prompt for username/password. If nil, no prompting is done Reader io.Reader // Writer is used to output prompts. If nil, stdout is used Writer io.Writer // Username is the username to use when challenged. If empty, a `BasicAuthNoUsernameError` is returned // when handling the challenge. Username string // Password is the password to use when challenged. If empty, a prompt is issued to a non-nil Reader Password string // contains filtered or unexported fields }
BasicChallengeHandler handles the "WWW-Authenticate: Basic" challenges. It implements the `ChallengeHandler` interface.
func NewBasicChallengeHandler ¶
func NewBasicChallengeHandler( host, consoleURL string, reader io.Reader, writer io.Writer, passwordPrompter PasswordPrompter, username, password string, ) *BasicChallengeHandler
func (*BasicChallengeHandler) CanHandle ¶
func (c *BasicChallengeHandler) CanHandle(headers http.Header) bool
func (*BasicChallengeHandler) CompleteChallenge ¶
func (c *BasicChallengeHandler) CompleteChallenge(requestURL string, headers http.Header) error
func (*BasicChallengeHandler) HandleChallenge ¶
func (c *BasicChallengeHandler) HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error)
HandleChallenge attempts to handle the "WWW-Authenticate: Basic" challenge. It may prompt for a password matching the username that should already be a part of the BasicChallengeHandler. The prompt is supposed to be called only once but this assertion is thread unsafe.
func (*BasicChallengeHandler) Release ¶
func (c *BasicChallengeHandler) Release() error
type ChallengeHandler ¶
type ChallengeHandler interface { // CanHandle returns true if the handler recognizes a challenge it thinks it can handle. CanHandle(headers http.Header) bool // HandleChallenge lets the handler attempt to handle a challenge. // It is only invoked if CanHandle() returned true for the given headers. // Returns response headers and true if the challenge is successfully handled. // Returns false if the challenge was not handled, and an optional error in error cases. HandleChallenge(requestURL string, headers http.Header) (http.Header, bool, error) // CompleteChallenge is invoked with the headers from a successful server response // received after having handled one or more challenges. // Returns an error if the handler does not consider the challenge/response interaction complete. CompleteChallenge(requestURL string, headers http.Header) error // Release gives the handler a chance to release any resources held during a challenge/response sequence. // It is always invoked, even in cases where no challenges were received or handled. Release() error }
ChallengeHandler handles responses to WWW-Authenticate challenges.
func NewMultiHandler ¶
func NewMultiHandler(handlers ...ChallengeHandler) ChallengeHandler
type MultiHandler ¶
type MultiHandler struct {
// contains filtered or unexported fields
}
MultiHandler manages a series of authentication challenges it is single-use only, and not thread-safe
func (*MultiHandler) CompleteChallenge ¶
func (h *MultiHandler) CompleteChallenge(requestURL string, headers http.Header) error
func (*MultiHandler) HandleChallenge ¶
func (*MultiHandler) Handlers ¶
func (h *MultiHandler) Handlers() []ChallengeHandler
func (*MultiHandler) Release ¶
func (h *MultiHandler) Release() error