internal

package
v2.11.4 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 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

func SetRequesterAddress(addr string) auth.Option

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

func SetRequesterBasicAuth

func SetRequesterBasicAuth(username, password string) auth.Option

SetRequesterBasicAuth sets ruqester basic auth.

func SetRequesterBearerToken

func SetRequesterBearerToken(token string) auth.Option

SetRequesterBearerToken sets ruqester token.

func SetRequesterClientTransport

func SetRequesterClientTransport(rt http.RoundTripper) auth.Option

SetRequesterClientTransport sets underlying requester http client transport.

func SetRequesterEndpoint

func SetRequesterEndpoint(endpoint string) auth.Option

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

func SetRequesterHTTPClient

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

SetRequesterHTTPClient sets underlying requester http client.

func SetRequesterMethod

func SetRequesterMethod(method string) auth.Option

SetRequesterMethod sets ruqester http method.

func SetRequesterTLSConfig

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

SetRequesterTLSConfig sets underlying requester http client tls config.

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 Hasher

type Hasher interface {
	Hash(string) string
}

Hasher represents a hash generator.

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

func NewRequester(addr string) *Requester

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.

func (*Requester) DoWithf

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

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