challenge

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Challenge

type Challenge struct {
	// Scheme is the auth-scheme according to RFC 2617
	Scheme string

	// Parameters are the auth-params according to RFC 2617
	Parameters map[string]string
}

Challenge carries information from a WWW-Authenticate response header. See RFC 2617.

func ResponseChallenges

func ResponseChallenges(resp *http.Response) []Challenge

ResponseChallenges returns a list of authorization challenges for the given http Response. Challenges are only checked if the response status code was a 401.

type FilteringManager added in v3.1.0

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

FilteringManager decorates another Manager and drops challenges that do not satisfy the configured predicate.

func (FilteringManager) AddResponse added in v3.1.0

func (m FilteringManager) AddResponse(resp *http.Response) error

func (FilteringManager) GetChallenges added in v3.1.0

func (m FilteringManager) GetChallenges(endpoint url.URL) ([]Challenge, error)

type Manager

type Manager interface {
	// GetChallenges returns the challenges for the given
	// endpoint URL.
	GetChallenges(endpoint url.URL) ([]Challenge, error)

	// AddResponse adds the response to the challenge
	// manager. The challenges will be parsed out of
	// the WWW-Authenticate headers and added to the
	// URL which was produced the response. If the
	// response was authorized, any challenges for the
	// endpoint will be cleared.
	AddResponse(resp *http.Response) error
}

Manager manages the challenges for endpoints. The challenges are pulled out of HTTP responses. Only responses which expect challenges should be added to the manager, since a non-unauthorized request will be viewed as not requiring challenges.

func NewFilteringManager added in v3.1.0

func NewFilteringManager(base Manager, keep func(Challenge) bool) Manager

NewFilteringManager returns a Manager that delegates storage to base and filters challenges on reads. If keep is nil, the base manager is returned.

func NewSimpleManager

func NewSimpleManager() Manager

NewSimpleManager returns an instance of Manager which only maps endpoints to challenges based on the responses which have been added the manager. The simple manager will make no attempt to perform requests on the endpoints or cache the responses to a backend.

Jump to

Keyboard shortcuts

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