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 ¶
SetRequesterAddress sets requester origin server address e.g http://host:port or https://host:port.
func SetRequesterBasicAuth ¶
SetRequesterBasicAuth sets ruqester basic auth.
func SetRequesterBearerToken ¶
SetRequesterBearerToken sets ruqester token.
func SetRequesterClientTransport ¶
func SetRequesterClientTransport(rt http.RoundTripper) auth.Option
SetRequesterClientTransport sets underlying requester http client transport.
func SetRequesterEndpoint ¶
SetRequesterEndpoint sets requester origin server endpoint. e.g /api/v1/token
func SetRequesterHTTPClient ¶
SetRequesterHTTPClient sets underlying requester http client.
func SetRequesterMethod ¶
SetRequesterMethod sets ruqester http method.
Types ¶
type HMACHasher ¶
type HMACHasher struct {
// contains filtered or unexported fields
}
HMACHasher implements the hasher interface and hash input using HMAC hashing alg.
func NewHMACHasher ¶
func NewHMACHasher(h crypto.Hash, key []byte) *HMACHasher
NewHMACHasher return new hmac hasher instance.
func (HMACHasher) Hash ¶
func (hm HMACHasher) Hash(str string) string
Hash str and return output as base64.
type PlainTextHasher ¶
type PlainTextHasher struct{}
PlainTextHasher implements the hasher interface and return input as is without hashing it.
func (PlainTextHasher) Hash ¶
func (p PlainTextHasher) Hash(str string) string
Hash return str as is without hashing it.
type Requester ¶
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 ¶
NewRequester returns new requester instance.
func (*Requester) Do ¶
func (r *Requester) Do(ctx context.Context, data, review, status interface{}) (*http.Response, error)
Do sends the HTTP request and parse the HTTP response.