security

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRandomToken

func NewRandomToken(length int) (string, error)

func RejectBannedIPs

func RejectBannedIPs(bannedIPs *MaxBadAttemptsBanList) mux.MiddlewareFunc

func TLSConfig

func TLSConfig(configTLSMin string) *tls.Config

Types

type BanList

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

func NewBanList

func NewBanList(banDuration time.Duration) *BanList

func (*BanList) Add

func (l *BanList) Add(visitorKey string)

func (*BanList) IsBanned

func (l *BanList) IsBanned(visitorKey string) bool

type MaxBadAttemptsBanList

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

MaxBadAttemptsBanList bans visitors by their keys after N failed consecutive attempts for Z period.

func NewMaxBadAttemptsBanList

func NewMaxBadAttemptsBanList(maxBadAttempts int, banDuration time.Duration, logger *logger.Logger) *MaxBadAttemptsBanList

func (*MaxBadAttemptsBanList) AddBadAttempt

func (l *MaxBadAttemptsBanList) AddBadAttempt(visitorKey string)

AddBadAttempt registers a bad attempt of a visitor.

func (*MaxBadAttemptsBanList) AddSuccessAttempt

func (l *MaxBadAttemptsBanList) AddSuccessAttempt(visitorKey string)

AddSuccessAttempt registers a successful attempt of a visitor.

func (*MaxBadAttemptsBanList) IsBanned

func (l *MaxBadAttemptsBanList) IsBanned(visitorKey string) bool

IsBanned checks whether a given visitor is banned or not.

Jump to

Keyboard shortcuts

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