apikey

package
v0.1.78 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

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

Authorizer implements the security.Authorizer interface for an api key based authorization.

func NewAuthorizer

func NewAuthorizer(authConfig *Config, apiKey string) *Authorizer

NewAuthorizer returns a new Authorizer for api key authorization with a config and a valid api key.

func (*Authorizer) Authorize

func (a *Authorizer) Authorize(r *http.Request, w http.ResponseWriter) (context.Context, bool)

Authorize authorizes a request based on the configured api key the config of the security schema Success: A context with a token containing the api key and true Error: the unchanged request context and false. the response already contains the error message

func (*Authorizer) CanAuthorizeRequest added in v0.1.27

func (a *Authorizer) CanAuthorizeRequest(r http.Request) bool

CanAuthorizeRequest returns true, if the request contains a token in the configured header, otherwise false

type Config

type Config struct {
	// currently not used
	Description string
	// Must be "Header"
	In string
	// Header field name, should never be "Authorization" if OAuth2 and ApiKey Authorization is combined
	Name string
}

Config contains the configuration of the security schema with type "apiKey".

Jump to

Keyboard shortcuts

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