auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AuthTokensDef []*TokenDef
	AuthTokens    map[string]string
}

Config contains the authorization token configuration.

type HandlerWrapper

type HandlerWrapper struct {
	common.HTTPHandler
	// contains filtered or unexported fields
}

HandlerWrapper wraps an existing HTTP handler and performs bearer token authorization. If authorized then the wrapped handler is invoked.

func NewHandlerWrapper

func NewHandlerWrapper(cfg Config, handler common.HTTPHandler) *HandlerWrapper

NewHandlerWrapper returns a handler that first performs bearer token authorization and, if authorized, invokes the wrapped handler.

func (*HandlerWrapper) Handler

Handler returns the 'wrapper' handler.

type TokenDef

type TokenDef struct {
	EndpointExpression string
	ReadTokens         []string
	WriteTokens        []string
}

TokenDef contains authorization bearer token definitions.

type TokenVerifier

type TokenVerifier struct {
	Config
	// contains filtered or unexported fields
}

TokenVerifier authorizes requests with bearer tokens.

func NewTokenVerifier

func NewTokenVerifier(cfg Config, endpoint, method string) *TokenVerifier

NewTokenVerifier returns a verifier that performs bearer token authorization.

func (*TokenVerifier) Verify

func (h *TokenVerifier) Verify(req *http.Request) bool

Verify verifies that the request has the required bearer token. If not, false is returned.

Jump to

Keyboard shortcuts

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