bells

package
v0.0.0-...-8da91eb Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChristmasTree

func ChristmasTree(h http.Handler) http.Handler

ChristmasTree adds a Christmas Tree to a header!

func LogEntrySetField

func LogEntrySetField(r *http.Request, key string, value interface{})

func LogEntrySetFields

func LogEntrySetFields(r *http.Request, fields map[string]interface{})

func LogrusLogger

func LogrusLogger() func(next http.Handler) http.Handler

LogrusLogger attempts to log the important things for credential stuffing detection

func RateLimitDevice

func RateLimitDevice(h http.Handler) http.Handler

RateLimitDevice is some middleware to rate limit requests by devices.

func RateLimitIP

func RateLimitIP(h http.Handler) http.Handler

RateLimitIP is some middleware to rate limit requests by IP address.

func UserID

func UserID(h http.Handler) http.Handler

UserID adds a SHA256 hash of the username to the logs when passed as a body entry.

Types

type DeviceRateLimiter

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

DeviceRateLimiter represents a collection of rate limiters for devices

func NewDeviceRateLimiter

func NewDeviceRateLimiter(limit rate.Limit, bucket int) *DeviceRateLimiter

NewDeviceRateLimiter creates a new collection of rate limiters for devices

func (*DeviceRateLimiter) AddDevice

func (limiter *DeviceRateLimiter) AddDevice(device string) *rate.Limiter

AddDevice creates a new rate limiter for a device, and adds it to the collection

func (*DeviceRateLimiter) GetLimiter

func (limiter *DeviceRateLimiter) GetLimiter(device string) *rate.Limiter

GetLimiter fetches a rate limiter for a given device from the collection and otherwise adds one to the collection if not found

type IPRateLimiter

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

IPRateLimiter represents a collection of rate limiters for IP addresses

func NewIPRateLimiter

func NewIPRateLimiter(limit rate.Limit, bucket int) *IPRateLimiter

NewIPRateLimiter creates a new collection of rate limiters for IP addresses

func (*IPRateLimiter) AddIP

func (limiter *IPRateLimiter) AddIP(ip string) *rate.Limiter

AddIP creates a new rate limiter for an IP, and adds it to the collection

func (*IPRateLimiter) GetLimiter

func (limiter *IPRateLimiter) GetLimiter(ip string) *rate.Limiter

GetLimiter fetches a rate limiter for a given IP from the collection and otherwise adds one to the collection if not found

type StructuredLogger

type StructuredLogger struct {
	Logger *logrus.Logger
}

func (*StructuredLogger) NewLogEntry

func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry

type StructuredLoggerEntry

type StructuredLoggerEntry struct {
	Logger logrus.FieldLogger
}

func (*StructuredLoggerEntry) Panic

func (l *StructuredLoggerEntry) Panic(v interface{}, stack []byte)

func (*StructuredLoggerEntry) Write

func (l *StructuredLoggerEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{})

Jump to

Keyboard shortcuts

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