guard

package
v0.0.0-...-89fb8e2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthUser

type AuthUser struct {
	User     string
	Password string
}

AuthUser is a type holding a username and password

type BasicAuth

type BasicAuth struct {
	Realm               string
	Users               map[string]AuthUser
	AuthFunc            func(string, string, *http.Request) bool
	UnauthorizedHandler router.ErrorHandler
}

BasicAuth provides HTTP middleware for protecting URIs with HTTP Basic Authentication as per RFC 2617. The server authenticates a user:password combination provided in the "Authorization" HTTP header.

Note: HTTP Basic Authentication credentials are sent in plain text, and therefore it does not make for a wholly secure authentication mechanism. You should serve your content over HTTPS to mitigate this, noting that "Basic Authentication" is meant to be just that: basic!

func SimpleBasicAuth

func SimpleBasicAuth(users map[string]string) *BasicAuth

SimpleBasicAuth takes a map with usernames and corresponding passwords, and returns a BasicAuth struct that can be used as middleware to handle basic user autentication.

func (BasicAuth) Authenticate

func (b BasicAuth) Authenticate(handler http.HandlerFunc) http.HandlerFunc

Authenticate is a middleware function that adds HTTP BasicAuth to a http handler

type Firewall

type Firewall struct {
	Blacklisting bool
	Subpath      bool
	Rules        map[string][]string
	ErrorHandler router.ErrorHandler
}

Firewall is type that holds multiple middleware functions to add a firewall to http handlers

func NewFirewall

func NewFirewall() *Firewall

NewFirewall returns a *Firewall type

func (*Firewall) BlockHTTP

func (f *Firewall) BlockHTTP(handler http.HandlerFunc) http.HandlerFunc

BlockHTTP is a middleware function to add a firewall to HTTP handlers

func (*Firewall) BlockProxy

func (f *Firewall) BlockProxy(handler http.HandlerFunc) http.HandlerFunc

BlockProxy is a middleware function to add a firewall to HTTP proxy

type Limiter

type Limiter struct {
	RatePerSec   rate.Limit
	RateBurst    int
	ErrorHandler router.ErrorHandler
	FilterOnIP   bool
	// contains filtered or unexported fields
}

Limiter is a type containing a MaguroHTTP Guard limiter

func NewLimiter

func NewLimiter(ratePerMin float64, rateBurst int, filterIP bool) *Limiter

NewLimiter returns a new guard.Limiter

func (*Limiter) LimitHTTP

func (l *Limiter) LimitHTTP(h http.HandlerFunc) http.HandlerFunc

LimitHTTP is a HTTP middleware function that can be used to add rate limiting to HTTP handlers.

Jump to

Keyboard shortcuts

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