2019-04-24 21:52:08 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2021-11-23 09:45:38 +00:00
|
|
|
"context"
|
2019-04-24 21:52:08 +00:00
|
|
|
"time"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/models"
|
2019-04-24 21:52:08 +00:00
|
|
|
)
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
// Provider is an interface providing storage capabilities for persisting any kind of data related to Authelia.
|
2019-04-24 21:52:08 +00:00
|
|
|
type Provider interface {
|
2021-11-23 09:45:38 +00:00
|
|
|
models.StartupCheck
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
RegulatorProvider
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
SavePreferred2FAMethod(ctx context.Context, username string, method string) (err error)
|
|
|
|
LoadPreferred2FAMethod(ctx context.Context, username string) (method string, err error)
|
|
|
|
LoadUserInfo(ctx context.Context, username string) (info models.UserInfo, err error)
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
SaveIdentityVerification(ctx context.Context, verification models.IdentityVerification) (err error)
|
2021-12-03 00:04:11 +00:00
|
|
|
ConsumeIdentityVerification(ctx context.Context, jti string, ip models.NullIP) (err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
FindIdentityVerification(ctx context.Context, jti string) (found bool, err error)
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
SaveTOTPConfiguration(ctx context.Context, config models.TOTPConfiguration) (err error)
|
2022-03-03 11:20:43 +00:00
|
|
|
UpdateTOTPConfigurationSignIn(ctx context.Context, id int, lastUsedAt *time.Time) (err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
DeleteTOTPConfiguration(ctx context.Context, username string) (err error)
|
|
|
|
LoadTOTPConfiguration(ctx context.Context, username string) (config *models.TOTPConfiguration, err error)
|
2021-11-25 01:56:58 +00:00
|
|
|
LoadTOTPConfigurations(ctx context.Context, limit, page int) (configs []models.TOTPConfiguration, err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2022-03-03 11:20:43 +00:00
|
|
|
SaveWebauthnDevice(ctx context.Context, device models.WebauthnDevice) (err error)
|
|
|
|
UpdateWebauthnDeviceSignIn(ctx context.Context, id int, rpid string, lastUsedAt *time.Time, signCount uint32, cloneWarning bool) (err error)
|
|
|
|
LoadWebauthnDevices(ctx context.Context, limit, page int) (devices []models.WebauthnDevice, err error)
|
|
|
|
LoadWebauthnDevicesByUsername(ctx context.Context, username string) (devices []models.WebauthnDevice, err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2021-12-01 03:32:58 +00:00
|
|
|
SavePreferredDuoDevice(ctx context.Context, device models.DuoDevice) (err error)
|
|
|
|
DeletePreferredDuoDevice(ctx context.Context, username string) (err error)
|
|
|
|
LoadPreferredDuoDevice(ctx context.Context, username string) (device *models.DuoDevice, err error)
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
SchemaTables(ctx context.Context) (tables []string, err error)
|
|
|
|
SchemaVersion(ctx context.Context) (version int, err error)
|
2021-12-01 03:32:58 +00:00
|
|
|
SchemaLatestVersion() (version int, err error)
|
|
|
|
|
2021-11-23 09:45:38 +00:00
|
|
|
SchemaMigrate(ctx context.Context, up bool, version int) (err error)
|
|
|
|
SchemaMigrationHistory(ctx context.Context) (migrations []models.Migration, err error)
|
2021-12-01 12:11:29 +00:00
|
|
|
SchemaMigrationsUp(ctx context.Context, version int) (migrations []models.SchemaMigration, err error)
|
|
|
|
SchemaMigrationsDown(ctx context.Context, version int) (migrations []models.SchemaMigration, err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2021-11-25 01:56:58 +00:00
|
|
|
SchemaEncryptionChangeKey(ctx context.Context, encryptionKey string) (err error)
|
|
|
|
SchemaEncryptionCheckKey(ctx context.Context, verbose bool) (err error)
|
|
|
|
|
|
|
|
Close() (err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegulatorProvider is an interface providing storage capabilities for persisting any kind of data related to the regulator.
|
|
|
|
type RegulatorProvider interface {
|
|
|
|
AppendAuthenticationLog(ctx context.Context, attempt models.AuthenticationAttempt) (err error)
|
|
|
|
LoadAuthenticationLogs(ctx context.Context, username string, fromDate time.Time, limit, page int) (attempts []models.AuthenticationAttempt, err error)
|
2019-04-24 21:52:08 +00:00
|
|
|
}
|