Documentation ¶
Overview ¶
Package internal contains support & helpers for go-guardian packages.
Index ¶
- func ParseAuthorizationHeader(key string, r *http.Request, err error) (string, error)
- func ParseCookie(key string, r *http.Request, e error) (string, error)
- func ParseHeader(header string, r *http.Request, err error) (string, error)
- func ParseJSONBody(key string, r *http.Request, err error) (string, error)
- func ParseQuery(key string, r *http.Request, err error) (string, error)
- func SetRequesterAddress(addr string) auth.Option
- func SetRequesterBasicAuth(username, password string) auth.Option
- func SetRequesterBearerToken(token string) auth.Option
- func SetRequesterClientTransport(rt http.RoundTripper) auth.Option
- func SetRequesterEndpoint(endpoint string) auth.Option
- func SetRequesterHTTPClient(c *http.Client) auth.Option
- func SetRequesterMethod(method string) auth.Option
- func SetRequesterTLSConfig(tls *tls.Config) auth.Option
- type HMACHasher
- type Hasher
- type PlainTextHasher
- type Requester
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAuthorizationHeader ¶
ParseAuthorizationHeader extract Authorization header value or return provided error.
func ParseCookie ¶
ParseCookie extract key value form form HTTP Cookie or return provided error.
func ParseHeader ¶
ParseHeader extract specific header value or return provided error.
func ParseJSONBody ¶
ParseJSONBody extract key value form HTTP request json body or return provided error.
func ParseQuery ¶
ParseQuery extract key value form HTTP query string or return provided error.
func SetRequesterAddress ¶ added in v2.6.1
SetRequesterAddress sets requester origin server address e.g http://host:port or https://host:port.
func SetRequesterBasicAuth ¶ added in v2.10.0
SetRequesterBasicAuth sets ruqester basic auth.
func SetRequesterBearerToken ¶ added in v2.6.1
SetRequesterBearerToken sets ruqester token.
func SetRequesterClientTransport ¶ added in v2.6.1
func SetRequesterClientTransport(rt http.RoundTripper) auth.Option
SetRequesterClientTransport sets underlying requester http client transport.
func SetRequesterEndpoint ¶ added in v2.6.1
SetRequesterEndpoint sets requester origin server endpoint. e.g /api/v1/token
func SetRequesterHTTPClient ¶ added in v2.6.1
SetRequesterHTTPClient sets underlying requester http client.
func SetRequesterMethod ¶ added in v2.10.0
SetRequesterMethod sets ruqester http method.
Types ¶
type HMACHasher ¶ added in v2.6.2
type HMACHasher struct {
// contains filtered or unexported fields
}
HMACHasher implements the hasher interface and hash input using HMAC hashing alg.
func NewHMACHasher ¶ added in v2.6.2
func NewHMACHasher(h crypto.Hash, key []byte) *HMACHasher
NewHMACHasher return new hmac hasher instance.
func (HMACHasher) Hash ¶ added in v2.6.2
func (hm HMACHasher) Hash(str string) string
Hash str and return output as base64.
type PlainTextHasher ¶ added in v2.6.2
type PlainTextHasher struct{}
PlainTextHasher implements the hasher interface and return input as is without hashing it.
func (PlainTextHasher) Hash ¶ added in v2.6.2
func (p PlainTextHasher) Hash(str string) string
Hash return str as is without hashing it.
type Requester ¶ added in v2.6.1
type Requester struct { Addr string Endpoint string Method string // Keep Unmarshalling body for all given types, by default stop after the first match KeepUnmarshalling bool Client *http.Client // AdditionalData add more data to http request AdditionalData func(r *http.Request) Unmarshal func(data []byte, v interface{}) error Marshal func(v interface{}) ([]byte, error) }
Requester sends an HTTP request to query an authorization server to determine the active state of an access token and to determine meta-information about this token.
func NewRequester ¶ added in v2.10.0
NewRequester returns new requester instance.
func (*Requester) Do ¶ added in v2.6.1
func (r *Requester) Do(ctx context.Context, data, review, status interface{}) (*http.Response, error)
Do sends the HTTP request and parse the HTTP response.