internal

package
v2.11.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package internal contains support & helpers for go-guardian packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAuthorizationHeader

func ParseAuthorizationHeader(key string, r *http.Request, err error) (string, error)

ParseAuthorizationHeader extract Authorization header value or return provided error.

func ParseCookie

func ParseCookie(key string, r *http.Request, e error) (string, error)

ParseCookie extract key value form form HTTP Cookie or return provided error.

func ParseHeader

func ParseHeader(header string, r *http.Request, err error) (string, error)

ParseHeader extract specific header value or return provided error.

func ParseJSONBody

func ParseJSONBody(key string, r *http.Request, err error) (string, error)

ParseJSONBody extract key value form HTTP request json body or return provided error.

func ParseQuery

func ParseQuery(key string, r *http.Request, err error) (string, error)

ParseQuery extract key value form HTTP query string or return provided error.

func SetRequesterAddress added in v2.6.1

func SetRequesterAddress(addr string) auth.Option

SetRequesterAddress sets requester origin server address e.g http://host:port or https://host:port.

func SetRequesterBasicAuth added in v2.10.0

func SetRequesterBasicAuth(username, password string) auth.Option

SetRequesterBasicAuth sets ruqester basic auth.

func SetRequesterBearerToken added in v2.6.1

func SetRequesterBearerToken(token string) auth.Option

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

func SetRequesterEndpoint(endpoint string) auth.Option

SetRequesterEndpoint sets requester origin server endpoint. e.g /api/v1/token

func SetRequesterHTTPClient added in v2.6.1

func SetRequesterHTTPClient(c *http.Client) auth.Option

SetRequesterHTTPClient sets underlying requester http client.

func SetRequesterMethod added in v2.10.0

func SetRequesterMethod(method string) auth.Option

SetRequesterMethod sets ruqester http method.

func SetRequesterTLSConfig added in v2.6.1

func SetRequesterTLSConfig(tls *tls.Config) auth.Option

SetRequesterTLSConfig sets underlying requester http client tls config.

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 Hasher added in v2.6.2

type Hasher interface {
	Hash(string) string
}

Hasher represents a hash generator.

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

func NewRequester(addr string) *Requester

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.

func (*Requester) DoWithf added in v2.10.0

func (r *Requester) DoWithf(ctx context.Context, f func(*http.Request), data, review, status interface{}) (*http.Response, error)

DoWithf same as Do but it accepts f to add additional information to the request.

func (*Requester) SetHeader added in v2.10.0

func (r *Requester) SetHeader(key, value string)

SetHeader for all outgoing request's.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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