2019-04-25 04:52:08 +07:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2021-11-23 16:45:38 +07:00
|
|
|
"context"
|
2019-04-25 04:52:08 +07:00
|
|
|
"time"
|
|
|
|
|
2022-04-07 12:33:53 +07:00
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/ory/fosite/storage"
|
|
|
|
|
2022-03-06 12:47:40 +07:00
|
|
|
"github.com/authelia/authelia/v4/internal/model"
|
2019-04-25 04:52:08 +07:00
|
|
|
)
|
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
// Provider is an interface providing storage capabilities for persisting any kind of data related to Authelia.
|
2019-04-25 04:52:08 +07:00
|
|
|
type Provider interface {
|
2022-03-06 12:47:40 +07:00
|
|
|
model.StartupCheck
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
RegulatorProvider
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2022-04-07 12:33:53 +07:00
|
|
|
storage.Transactional
|
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
SavePreferred2FAMethod(ctx context.Context, username string, method string) (err error)
|
|
|
|
LoadPreferred2FAMethod(ctx context.Context, username string) (method string, err error)
|
2022-03-06 12:47:40 +07:00
|
|
|
LoadUserInfo(ctx context.Context, username string) (info model.UserInfo, err error)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2022-04-07 12:33:53 +07:00
|
|
|
SaveUserOpaqueIdentifier(ctx context.Context, subject model.UserOpaqueIdentifier) (err error)
|
|
|
|
LoadUserOpaqueIdentifier(ctx context.Context, opaqueUUID uuid.UUID) (subject *model.UserOpaqueIdentifier, err error)
|
2022-04-09 14:13:19 +07:00
|
|
|
LoadUserOpaqueIdentifiers(ctx context.Context) (opaqueIDs []model.UserOpaqueIdentifier, err error)
|
2022-04-07 12:33:53 +07:00
|
|
|
LoadUserOpaqueIdentifierBySignature(ctx context.Context, service, sectorID, username string) (subject *model.UserOpaqueIdentifier, err error)
|
|
|
|
|
2022-03-06 12:47:40 +07:00
|
|
|
SaveIdentityVerification(ctx context.Context, verification model.IdentityVerification) (err error)
|
|
|
|
ConsumeIdentityVerification(ctx context.Context, jti string, ip model.NullIP) (err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
FindIdentityVerification(ctx context.Context, jti string) (found bool, err error)
|
2019-04-25 04:52:08 +07:00
|
|
|
|
2022-03-06 12:47:40 +07:00
|
|
|
SaveTOTPConfiguration(ctx context.Context, config model.TOTPConfiguration) (err error)
|
2022-03-03 18:20:43 +07:00
|
|
|
UpdateTOTPConfigurationSignIn(ctx context.Context, id int, lastUsedAt *time.Time) (err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
DeleteTOTPConfiguration(ctx context.Context, username string) (err error)
|
2022-03-06 12:47:40 +07:00
|
|
|
LoadTOTPConfiguration(ctx context.Context, username string) (config *model.TOTPConfiguration, err error)
|
|
|
|
LoadTOTPConfigurations(ctx context.Context, limit, page int) (configs []model.TOTPConfiguration, err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
|
2022-03-06 12:47:40 +07:00
|
|
|
SaveWebauthnDevice(ctx context.Context, device model.WebauthnDevice) (err error)
|
2022-03-03 18:20:43 +07:00
|
|
|
UpdateWebauthnDeviceSignIn(ctx context.Context, id int, rpid string, lastUsedAt *time.Time, signCount uint32, cloneWarning bool) (err error)
|
2022-03-06 12:47:40 +07:00
|
|
|
LoadWebauthnDevices(ctx context.Context, limit, page int) (devices []model.WebauthnDevice, err error)
|
|
|
|
LoadWebauthnDevicesByUsername(ctx context.Context, username string) (devices []model.WebauthnDevice, err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
|
2022-03-06 12:47:40 +07:00
|
|
|
SavePreferredDuoDevice(ctx context.Context, device model.DuoDevice) (err error)
|
2021-12-01 10:32:58 +07:00
|
|
|
DeletePreferredDuoDevice(ctx context.Context, username string) (err error)
|
2022-03-06 12:47:40 +07:00
|
|
|
LoadPreferredDuoDevice(ctx context.Context, username string) (device *model.DuoDevice, err error)
|
2021-12-01 10:32:58 +07:00
|
|
|
|
2022-04-07 12:33:53 +07:00
|
|
|
SaveOAuth2ConsentSession(ctx context.Context, consent model.OAuth2ConsentSession) (err error)
|
2022-04-25 07:31:05 +07:00
|
|
|
SaveOAuth2ConsentSessionSubject(ctx context.Context, consent model.OAuth2ConsentSession) (err error)
|
2022-04-07 12:33:53 +07:00
|
|
|
SaveOAuth2ConsentSessionResponse(ctx context.Context, consent model.OAuth2ConsentSession, rejection bool) (err error)
|
|
|
|
SaveOAuth2ConsentSessionGranted(ctx context.Context, id int) (err error)
|
|
|
|
LoadOAuth2ConsentSessionByChallengeID(ctx context.Context, challengeID uuid.UUID) (consent *model.OAuth2ConsentSession, err error)
|
|
|
|
LoadOAuth2ConsentSessionsPreConfigured(ctx context.Context, clientID string, subject uuid.UUID) (rows *ConsentSessionRows, err error)
|
|
|
|
|
|
|
|
SaveOAuth2Session(ctx context.Context, sessionType OAuth2SessionType, session model.OAuth2Session) (err error)
|
|
|
|
RevokeOAuth2Session(ctx context.Context, sessionType OAuth2SessionType, signature string) (err error)
|
|
|
|
RevokeOAuth2SessionByRequestID(ctx context.Context, sessionType OAuth2SessionType, requestID string) (err error)
|
|
|
|
DeactivateOAuth2Session(ctx context.Context, sessionType OAuth2SessionType, signature string) (err error)
|
|
|
|
DeactivateOAuth2SessionByRequestID(ctx context.Context, sessionType OAuth2SessionType, requestID string) (err error)
|
|
|
|
LoadOAuth2Session(ctx context.Context, sessionType OAuth2SessionType, signature string) (session *model.OAuth2Session, err error)
|
|
|
|
|
|
|
|
SaveOAuth2BlacklistedJTI(ctx context.Context, blacklistedJTI model.OAuth2BlacklistedJTI) (err error)
|
|
|
|
LoadOAuth2BlacklistedJTI(ctx context.Context, signature string) (blacklistedJTI *model.OAuth2BlacklistedJTI, err error)
|
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
SchemaTables(ctx context.Context) (tables []string, err error)
|
|
|
|
SchemaVersion(ctx context.Context) (version int, err error)
|
2021-12-01 10:32:58 +07:00
|
|
|
SchemaLatestVersion() (version int, err error)
|
|
|
|
|
2021-11-23 16:45:38 +07:00
|
|
|
SchemaMigrate(ctx context.Context, up bool, version int) (err error)
|
2022-03-06 12:47:40 +07:00
|
|
|
SchemaMigrationHistory(ctx context.Context) (migrations []model.Migration, err error)
|
|
|
|
SchemaMigrationsUp(ctx context.Context, version int) (migrations []model.SchemaMigration, err error)
|
|
|
|
SchemaMigrationsDown(ctx context.Context, version int) (migrations []model.SchemaMigration, err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
|
2021-11-25 08:56:58 +07:00
|
|
|
SchemaEncryptionChangeKey(ctx context.Context, encryptionKey string) (err error)
|
|
|
|
SchemaEncryptionCheckKey(ctx context.Context, verbose bool) (err error)
|
|
|
|
|
|
|
|
Close() (err error)
|
2021-11-23 16:45:38 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
// RegulatorProvider is an interface providing storage capabilities for persisting any kind of data related to the regulator.
|
|
|
|
type RegulatorProvider interface {
|
2022-03-06 12:47:40 +07:00
|
|
|
AppendAuthenticationLog(ctx context.Context, attempt model.AuthenticationAttempt) (err error)
|
|
|
|
LoadAuthenticationLogs(ctx context.Context, username string, fromDate time.Time, limit, page int) (attempts []model.AuthenticationAttempt, err error)
|
2019-04-25 04:52:08 +07:00
|
|
|
}
|