2019-04-24 21:52:08 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2021-11-23 09:45:38 +00:00
|
|
|
"context"
|
2022-10-20 02:16:36 +00:00
|
|
|
"database/sql"
|
2019-04-24 21:52:08 +00:00
|
|
|
"time"
|
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/ory/fosite/storage"
|
|
|
|
|
2022-03-06 05:47:40 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/model"
|
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 {
|
2022-03-06 05:47:40 +00:00
|
|
|
model.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
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
storage.Transactional
|
|
|
|
|
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)
|
2022-03-06 05:47:40 +00:00
|
|
|
LoadUserInfo(ctx context.Context, username string) (info model.UserInfo, err error)
|
2019-04-24 21:52:08 +00:00
|
|
|
|
2022-04-07 05:33:53 +00: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 07:13:19 +00:00
|
|
|
LoadUserOpaqueIdentifiers(ctx context.Context) (opaqueIDs []model.UserOpaqueIdentifier, err error)
|
2022-04-07 05:33:53 +00:00
|
|
|
LoadUserOpaqueIdentifierBySignature(ctx context.Context, service, sectorID, username string) (subject *model.UserOpaqueIdentifier, err error)
|
|
|
|
|
2022-03-06 05:47:40 +00:00
|
|
|
SaveIdentityVerification(ctx context.Context, verification model.IdentityVerification) (err error)
|
|
|
|
ConsumeIdentityVerification(ctx context.Context, jti string, ip model.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
|
|
|
|
2022-03-06 05:47:40 +00:00
|
|
|
SaveTOTPConfiguration(ctx context.Context, config model.TOTPConfiguration) (err error)
|
2022-10-20 02:16:36 +00:00
|
|
|
UpdateTOTPConfigurationSignIn(ctx context.Context, id int, lastUsedAt sql.NullTime) (err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
DeleteTOTPConfiguration(ctx context.Context, username string) (err error)
|
2022-03-06 05:47:40 +00: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 09:45:38 +00:00
|
|
|
|
2023-02-16 19:40:40 +00:00
|
|
|
SaveWebauthnUser(ctx context.Context, user model.WebauthnUser) (err error)
|
|
|
|
LoadWebauthnUser(ctx context.Context, rpid, username string) (user *model.WebauthnUser, err error)
|
|
|
|
|
2022-03-06 05:47:40 +00:00
|
|
|
SaveWebauthnDevice(ctx context.Context, device model.WebauthnDevice) (err error)
|
2022-11-19 05:48:47 +00:00
|
|
|
UpdateWebauthnDeviceDescription(ctx context.Context, username string, deviceID int, description string) (err error)
|
2023-02-14 02:53:57 +00:00
|
|
|
UpdateWebauthnDeviceSignIn(ctx context.Context, device model.WebauthnDevice) (err error)
|
2022-10-19 07:17:55 +00:00
|
|
|
DeleteWebauthnDevice(ctx context.Context, kid string) (err error)
|
|
|
|
DeleteWebauthnDeviceByUsername(ctx context.Context, username, description string) (err error)
|
2022-03-06 05:47:40 +00:00
|
|
|
LoadWebauthnDevices(ctx context.Context, limit, page int) (devices []model.WebauthnDevice, err error)
|
2023-02-11 15:47:03 +00:00
|
|
|
LoadWebauthnDevicesByUsername(ctx context.Context, rpid, username string) (devices []model.WebauthnDevice, err error)
|
2022-12-31 07:27:43 +00:00
|
|
|
LoadWebauthnDeviceByID(ctx context.Context, id int) (device *model.WebauthnDevice, err error)
|
2021-11-23 09:45:38 +00:00
|
|
|
|
2022-03-06 05:47:40 +00:00
|
|
|
SavePreferredDuoDevice(ctx context.Context, device model.DuoDevice) (err error)
|
2021-12-01 03:32:58 +00:00
|
|
|
DeletePreferredDuoDevice(ctx context.Context, username string) (err error)
|
2022-03-06 05:47:40 +00:00
|
|
|
LoadPreferredDuoDevice(ctx context.Context, username string) (device *model.DuoDevice, err error)
|
2021-12-01 03:32:58 +00:00
|
|
|
|
2022-10-20 02:16:36 +00:00
|
|
|
SaveOAuth2ConsentPreConfiguration(ctx context.Context, config model.OAuth2ConsentPreConfig) (insertedID int64, err error)
|
|
|
|
LoadOAuth2ConsentPreConfigurations(ctx context.Context, clientID string, subject uuid.UUID) (rows *ConsentPreConfigRows, err error)
|
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
SaveOAuth2ConsentSession(ctx context.Context, consent model.OAuth2ConsentSession) (err error)
|
2022-04-25 00:31:05 +00:00
|
|
|
SaveOAuth2ConsentSessionSubject(ctx context.Context, consent model.OAuth2ConsentSession) (err error)
|
2022-04-07 05:33:53 +00: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)
|
|
|
|
|
|
|
|
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 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)
|
2022-03-06 05:47:40 +00: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 09:45:38 +00:00
|
|
|
|
2022-11-25 12:44:55 +00:00
|
|
|
SchemaEncryptionChangeKey(ctx context.Context, key string) (err error)
|
|
|
|
SchemaEncryptionCheckKey(ctx context.Context, verbose bool) (result EncryptionValidationResult, err error)
|
2021-11-25 01:56:58 +00:00
|
|
|
|
|
|
|
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 {
|
2022-03-06 05:47:40 +00: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-24 21:52:08 +00:00
|
|
|
}
|