auth

package
v0.0.0-...-05cadd0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// KeyHeader contains secret private key of a remote service
	KeyHeader = "X-Auth-Sign"
	// CallerHeader contains name of a remote service
	CallerHeader = "X-Auth-Id"
)

Variables

This section is empty.

Functions

func GetCaller

func GetCaller(ctx context.Context) string

GetCaller returns a caller associated with the given context or 'unknown'.

func SetCaller

func SetCaller(ctx context.Context, caller string) context.Context

SetCaller returns a copy of context associated with the given caller.

Types

type Verifier

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

Verifier parses and verifies access keys.

func NewVerifier

func NewVerifier(logger log.Logger, accessFiles []string) (*Verifier, error)

NewVerifier creates a new Verifier.

func (*Verifier) GetAccessKey

func (v *Verifier) GetAccessKey(caller string) string

GetAccessKey returns a key associated with the given caller or ”.

func (*Verifier) Wrap

func (v *Verifier) Wrap(next http.HandlerFunc) http.HandlerFunc

Wrap wraps an HTTP handler with a middleware that acts as a access limiter. Requests which wouldn't have an access key are simply rejected with an error. The successfully verified caller is saved to the request's context.

Jump to

Keyboard shortcuts

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