2019-04-24 21:52:08 +00:00
|
|
|
package regulation
|
|
|
|
|
|
|
|
import (
|
2022-06-14 07:20:13 +00:00
|
|
|
"context"
|
|
|
|
"net"
|
|
|
|
|
2022-03-02 06:40:26 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
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
|
2022-03-02 06:40:26 +00:00
|
|
|
|
|
|
|
config schema.RegulationConfiguration
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2023-05-24 12:33:05 +00:00
|
|
|
store storage.RegulatorProvider
|
2019-11-24 20:27:59 +00:00
|
|
|
|
|
|
|
clock utils.Clock
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|
2022-06-14 07:20:13 +00:00
|
|
|
|
|
|
|
// Context represents a regulator context.
|
|
|
|
type Context interface {
|
|
|
|
context.Context
|
|
|
|
MetricsRecorder
|
|
|
|
|
|
|
|
RemoteIP() (ip net.IP)
|
|
|
|
}
|
|
|
|
|
|
|
|
// MetricsRecorder represents the methods used to record regulation.
|
|
|
|
type MetricsRecorder interface {
|
2023-01-25 09:36:40 +00:00
|
|
|
RecordAuthn(success, banned bool, authType string)
|
2022-06-14 07:20:13 +00:00
|
|
|
}
|