securityprovider

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package securityprovider contains some default securityprovider implementations, which can be used as a RequestEditorFn of a client.

Index

Constants

View Source
const (
	// ErrAPIKeyInvalidIn indicates a usage of an invalid In.
	// Should be cookie, header or query
	ErrAPIKeyInvalidIn = Error("invalid 'in' specified for apiKey")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	// contains filtered or unexported fields
}

APIKey will attach an apiKey either to a cookie, header or query.

func NewAPIKey

func NewAPIKey(in, name, apiKey string) (*APIKey, error)

NewAPIKey will attach a generic apiKey for a given name either to a cookie, header or as a query parameter.

func (*APIKey) Intercept

func (s *APIKey) Intercept(ctx context.Context, req *http.Request) error

Intercept will attach a cookie, header or query param for the configured name and apiKey.

type BasicAuth

type BasicAuth struct {
	// contains filtered or unexported fields
}

BasicAuth sends a base64-encoded combination of username, password along with a request.

func NewBasicAuth

func NewBasicAuth(username, password string) (*BasicAuth, error)

NewBasicAuth provides a BasicAuth, which can solve the BasicAuth challenge for api-calls.

func (*BasicAuth) Intercept

func (s *BasicAuth) Intercept(ctx context.Context, req *http.Request) error

Intercept will attach an Authorization header to the request and ensures that the username, password are base64 encoded and attached to the header.

type BearerToken

type BearerToken struct {
	// contains filtered or unexported fields
}

BearerToken sends a token as part of an Authorization: Bearer header along with a request.

func NewBearerToken

func NewBearerToken(token string) (*BearerToken, error)

NewBearerToken provides a BearerToken, which can solve the Bearer Auth challende for api-calls.

func (*BearerToken) Intercept

func (s *BearerToken) Intercept(ctx context.Context, req *http.Request) error

Intercept will attach an Authorization header to the request and ensures that the bearer token is attached to the header.

type Error

type Error string

Error defines error values of a security provider.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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