Documentation ¶
Overview ¶
Package digest provides authentication strategy, to authenticate HTTP requests using the standard digest scheme as described in RFC 7616.
Index ¶
- Constants
- Variables
- type CachedStrategy
- type Header
- func (h Header) Algorithm() string
- func (h Header) Cnonce() string
- func (h Header) Compare(ch Header) error
- func (h Header) NC() string
- func (h Header) Nonce() string
- func (h Header) Opaque() string
- func (h Header) Parse(authorization string) error
- func (h Header) QOP() string
- func (h Header) Realm() string
- func (h Header) Response() string
- func (h Header) SetAlgorithm(a string)
- func (h Header) SetCnonce(cn string)
- func (h Header) SetNC(n string)
- func (h Header) SetNonce(n string)
- func (h Header) SetOpaque(o string)
- func (h Header) SetQOP(q string)
- func (h Header) SetRealm(r string)
- func (h Header) SetResponse(r string)
- func (h Header) SetURI(u string)
- func (h Header) SetUserName(u string)
- func (h Header) String() string
- func (h Header) URI() string
- func (h Header) UserName() string
- func (h Header) WWWAuthenticate() (string, error)
- type Strategy
Constants ¶
const StrategyKey = auth.StrategyKey("Digest.Strategy")
StrategyKey export identifier for the digest strategy, commonly used when enable/add strategy to go-guardian authenticator.
Variables ¶
ErrInavlidHeader is returned by Header parse when authz header is not digest.
var ErrInvalidResponse = errors.New("Digest: Invalid Response")
ErrInvalidResponse is returned by Strategy when client authz response does not match server hash.
Functions ¶
This section is empty.
Types ¶
type CachedStrategy ¶
CachedStrategy caches digest strategy authentication response based on authorization nonce field.
func (*CachedStrategy) Authenticate ¶
Authenticate user request and returns user info, Otherwise error.
type Header ¶
Header represents The Authorization Header Field, and WWW-Authenticate Response Header Field as described in RFC 7616
func (Header) Algorithm ¶
Algorithm return a string indicating an hash algorithm used to produce the digest and an unkeyed digest.
func (Header) Compare ¶ added in v1.2.1
Compare server header vs client header returns error if any diff found.
func (Header) Realm ¶
Realm return a string to be displayed to users so they know which username and password to use. See https://tools.ietf.org/html/rfc7616#section-3.3
func (Header) SetAlgorithm ¶
SetAlgorithm sets hash algorithm.
func (Header) SetResponse ¶
SetResponse sets the client response.
func (Header) URI ¶
URI return Effective Request URI See https://tools.ietf.org/html/rfc7230#section-5.5
func (Header) WWWAuthenticate ¶
WWWAuthenticate return string represents HTTP WWW-Authenticate header field with Digest scheme.
type Strategy ¶
type Strategy struct { // Hash a callback function to return the desired hash algorithm, // the passed algo args is extracted from authorization header // and if it missing the args will be same as algorithm field provided to the strategy. Hash func(algo string) hash.Hash // FetchUser a callback function to return the user password and user info or error in case of occurs. FetchUser func(userName string) (string, auth.Info, error) Realm string Algorithm string }
Strategy implements auth.Strategy and represents digest authentication as described in RFC 7616.
func (*Strategy) Authenticate ¶
Authenticate user request and returns user info, Otherwise error.