2019-04-24 21:52:08 +00:00
|
|
|
package regulation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/storage"
|
|
|
|
"github.com/authelia/authelia/v4/internal/utils"
|
2019-04-24 21:52:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Regulator an authentication regulator preventing attackers to brute force the service.
|
|
|
|
type Regulator struct {
|
|
|
|
// Is the regulation enabled.
|
|
|
|
enabled bool
|
|
|
|
// The number of failed authentication attempt before banning the user
|
|
|
|
maxRetries int
|
|
|
|
// If a user does the max number of retries within that duration, she will be banned.
|
|
|
|
findTime time.Duration
|
|
|
|
// If a user has been banned, this duration is the timelapse during which the user is banned.
|
|
|
|
banTime time.Duration
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
storageProvider storage.RegulatorProvider
|
2019-11-24 20:27:59 +00:00
|
|
|
|
|
|
|
clock utils.Clock
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|