Documentation
¶
Overview ¶
Package acquire is used for getting Auths to pass in http requests.
Index ¶
- Variables
- func AddAuth(r *http.Request, acquirer Acquirer) error
- func DefaultExpirationParser(data []byte) (time.Time, error)
- func DefaultTokenParser(data []byte) (string, error)
- func RawTokenExpirationParser(data []byte) (time.Time, error)
- func RawTokenParser(data []byte) (string, error)
- type Acquirer
- type DefaultAcquirer
- type FixedValueAcquirer
- type ParseExpiration
- type RemoteBearerTokenAcquirer
- type RemoteBearerTokenAcquirerOptions
- type SimpleBearer
- type TokenParser
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyCredentials = errors.New("Empty credentials are not valid")
ErrEmptyCredentials is returned whenever an Acquirer is attempted to be built with empty credentials. Use DefaultAcquirer for such no-op use case.
Functions ¶
func DefaultExpirationParser ¶
DefaultExpirationParser extracts a bearer token expiration date as defined by a SimpleBearer in a payload.
func DefaultTokenParser ¶
DefaultTokenParser extracts a bearer token as defined by a SimpleBearer in a payload.
func RawTokenExpirationParser ¶ added in v0.10.1
func RawTokenParser ¶ added in v0.10.1
Types ¶
type Acquirer ¶
Acquirer gets an Authorization value that can be added to an http request. The format of the string returned should be the key, a space, and then the auth string: '[AuthType] [AuthValue]'
type DefaultAcquirer ¶
type DefaultAcquirer struct{}
DefaultAcquirer is a no-op Acquirer.
func (*DefaultAcquirer) Acquire ¶
func (d *DefaultAcquirer) Acquire() (string, error)
Acquire returns the zero values of the return types.
type FixedValueAcquirer ¶ added in v0.4.0
type FixedValueAcquirer struct {
// contains filtered or unexported fields
}
FixedValueAcquirer implements Acquirer with a constant authorization value.
func NewFixedAuthAcquirer ¶ added in v0.4.0
func NewFixedAuthAcquirer(authValue string) (*FixedValueAcquirer, error)
NewFixedAuthAcquirer returns a FixedValueAcquirer with the given authValue.
func (*FixedValueAcquirer) Acquire ¶ added in v0.4.0
func (f *FixedValueAcquirer) Acquire() (string, error)
type ParseExpiration ¶
ParseExpiration defines the function signature of a bearer token expiration date extractor.
type RemoteBearerTokenAcquirer ¶ added in v0.4.0
type RemoteBearerTokenAcquirer struct {
// contains filtered or unexported fields
}
RemoteBearerTokenAcquirer implements Acquirer and fetches the tokens from a remote location with caching strategy.
func NewRemoteBearerTokenAcquirer ¶ added in v0.4.0
func NewRemoteBearerTokenAcquirer(options RemoteBearerTokenAcquirerOptions) (*RemoteBearerTokenAcquirer, error)
NewRemoteBearerTokenAcquirer returns a RemoteBearerTokenAcquirer configured with the given options.
func (*RemoteBearerTokenAcquirer) Acquire ¶ added in v0.4.0
func (acquirer *RemoteBearerTokenAcquirer) Acquire() (string, error)
Acquire provides the cached token or, if it's near its expiry time, contacts the server for a new token to cache.
type RemoteBearerTokenAcquirerOptions ¶ added in v0.4.0
type RemoteBearerTokenAcquirerOptions struct { AuthURL string `json:"authURL"` Timeout time.Duration `json:"timeout"` Buffer time.Duration `json:"buffer"` RequestHeaders map[string]string `json:"requestHeaders"` GetToken TokenParser GetExpiration ParseExpiration }
RemoteBearerTokenAcquirerOptions provides configuration for the RemoteBearerTokenAcquirer.
type SimpleBearer ¶ added in v0.4.0
type SimpleBearer struct { ExpiresInSeconds float64 `json:"expires_in"` Token string `json:"serviceAccessToken"` }
SimpleBearer defines the field name mappings used by the default bearer token and expiration parsers.
type TokenParser ¶ added in v0.4.0
TokenParser defines the function signature of a bearer token extractor from a payload.