Documentation ¶
Index ¶
- func ChristmasTree(h http.Handler) http.Handler
- func LogEntrySetField(r *http.Request, key string, value interface{})
- func LogEntrySetFields(r *http.Request, fields map[string]interface{})
- func LogrusLogger() func(next http.Handler) http.Handler
- func RateLimitDevice(h http.Handler) http.Handler
- func RateLimitIP(h http.Handler) http.Handler
- func UserID(h http.Handler) http.Handler
- type DeviceRateLimiter
- type IPRateLimiter
- type StructuredLogger
- type StructuredLoggerEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChristmasTree ¶
ChristmasTree adds a Christmas Tree to a header!
func LogEntrySetField ¶
func LogEntrySetFields ¶
func LogrusLogger ¶
LogrusLogger attempts to log the important things for credential stuffing detection
func RateLimitDevice ¶
RateLimitDevice is some middleware to rate limit requests by devices.
func RateLimitIP ¶
RateLimitIP is some middleware to rate limit requests by IP address.
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 ¶
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)