bricks: Index | Files

package apikey

import ""


Package Files


type Authorizer Uses

type Authorizer struct {
    // contains filtered or unexported fields

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

func NewAuthorizer Uses

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 Uses

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 Uses

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 Uses

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 apikey imports 4 packages (graph). Updated 2020-03-20. Refresh now. Tools for package owners.