filter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultRealm = "Restricted"
)

Variables

This section is empty.

Functions

func RegisterNewFilterFunc

func RegisterNewFilterFunc(filterType string, fn NewFilterFunc)

RegisterNewFilterFunc registers a NewFilterFunc with filterType.

Types

type BasicAuth

type BasicAuth struct {
	Realm     string           `yaml:"realm"`
	Users     []*BasicAuthUser `yaml:"users"`
	UsersFile string           `yaml:"usersFile"`
}

BasicAuth implements Filter.

func NewBasicAuth

func NewBasicAuth(cfg tree.Map) (*BasicAuth, error)

NewBasicAuth returns a new BasicAuth.

func (*BasicAuth) Filter

func (f *BasicAuth) Filter(ctx *fasthttp.RequestCtx) bool

Filter examines the Authorization header of the given ctx and matches it against the user it holds. If the user does not match, it sets 401 Unauthorized and returns false.

type BasicAuthUser

type BasicAuthUser struct {
	Name   string `yaml:"name"`
	Secret string `yaml:"secret"`
	// contains filtered or unexported fields
}

BasicAuthUser represents a basic auth user.

type Filter

type Filter func(ctx *fasthttp.RequestCtx) bool

Filter is a function that filters ctx and returns bool (false means break filters).

func NewBasicAuthFilter

func NewBasicAuthFilter(cfg tree.Map) (Filter, error)

NewBasicAuthFilter returns a Filter of the BasicAuth.

func NewFilter

func NewFilter(cfg tree.Map) (Filter, error)

NewFilter returns a new filter.

type NewFilterFunc

type NewFilterFunc func(cfg tree.Map) (Filter, error)

NewFilterFunc is a function that returns a new filter.

Jump to

Keyboard shortcuts

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