lock

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package lock implements user locking after N bad sign-in attempts.

Index

Constants

View Source
const (
	StoreAttemptNumber = "attempt_number"
	StoreAttemptTime   = "attempt_time"
	StoreLocked        = "locked"
)

Storage key constants

Variables

This section is empty.

Functions

func IsLocked

func IsLocked(lu authboss.LockableUser) bool

IsLocked checks if a user is locked

func Middleware

func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler

Middleware ensures that a user is not locked, or else it will intercept the request and send them to the configured LockNotOK page, this will load the user if he's not been loaded yet from the session. And panics if it cannot load the user.

Types

type Lock

type Lock struct {
	*authboss.Authboss
}

Lock module

func (*Lock) AfterAuthFail

func (l *Lock) AfterAuthFail(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)

AfterAuthFail adjusts the attempt number and time negatively and locks the user if they're beyond limits.

func (*Lock) AfterAuthSuccess

func (l *Lock) AfterAuthSuccess(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)

AfterAuthSuccess resets the attempt number field.

func (*Lock) BeforeAuth

func (l *Lock) BeforeAuth(w http.ResponseWriter, r *http.Request, handled bool) (bool, error)

BeforeAuth ensures the account is not locked.

func (*Lock) Init

func (l *Lock) Init(ab *authboss.Authboss) error

Init the module

func (*Lock) Lock

func (l *Lock) Lock(ctx context.Context, key string) error

Lock a user manually.

func (*Lock) Unlock

func (l *Lock) Unlock(ctx context.Context, key string) error

Unlock a user that was locked by this module.

Jump to

Keyboard shortcuts

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