Back to godoc.org

Package apikey

v0.1.74
Latest Go to latest

The latest major version is .

Published: Sep 23, 2020 | License: MIT | Module: github.com/pace/bricks

Index

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

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".

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier