mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
0a970aef8a
This moves the OpenID Connect storage from memory into the SQL storage, making it persistent and allowing it to be used with clustered deployments like the rest of Authelia.
98 lines
3.0 KiB
Go
98 lines
3.0 KiB
Go
package storage
|
|
|
|
import (
|
|
"regexp"
|
|
)
|
|
|
|
const (
|
|
tableAuthenticationLogs = "authentication_logs"
|
|
tableDuoDevices = "duo_devices"
|
|
tableIdentityVerification = "identity_verification"
|
|
tableTOTPConfigurations = "totp_configurations"
|
|
tableUserOpaqueIdentifier = "user_opaque_identifier"
|
|
tableUserPreferences = "user_preferences"
|
|
tableWebauthnDevices = "webauthn_devices"
|
|
|
|
tableOAuth2ConsentSession = "oauth2_consent_session"
|
|
tableOAuth2AuthorizeCodeSession = "oauth2_authorization_code_session"
|
|
tableOAuth2AccessTokenSession = "oauth2_access_token_session" //nolint:gosec // This is not a hardcoded credential.
|
|
tableOAuth2RefreshTokenSession = "oauth2_refresh_token_session" //nolint:gosec // This is not a hardcoded credential.
|
|
tableOAuth2PKCERequestSession = "oauth2_pkce_request_session"
|
|
tableOAuth2OpenIDConnectSession = "oauth2_openid_connect_session"
|
|
tableOAuth2BlacklistedJTI = "oauth2_blacklisted_jti"
|
|
|
|
tableMigrations = "migrations"
|
|
tableEncryption = "encryption"
|
|
|
|
tablePrefixBackup = "_bkp_"
|
|
)
|
|
|
|
// OAuth2SessionType represents the potential OAuth 2.0 session types.
|
|
type OAuth2SessionType string
|
|
|
|
// Representation of specific OAuth 2.0 session types.
|
|
const (
|
|
OAuth2SessionTypeAuthorizeCode OAuth2SessionType = "authorization code"
|
|
OAuth2SessionTypeAccessToken OAuth2SessionType = "access token"
|
|
OAuth2SessionTypeRefreshToken OAuth2SessionType = "refresh token"
|
|
OAuth2SessionTypePKCEChallenge OAuth2SessionType = "pkce challenge"
|
|
OAuth2SessionTypeOpenIDConnect OAuth2SessionType = "openid connect"
|
|
)
|
|
|
|
const (
|
|
encryptionNameCheck = "check"
|
|
)
|
|
|
|
// WARNING: Do not change/remove these consts. They are used for Pre1 migrations.
|
|
const (
|
|
tablePre1TOTPSecrets = "totp_secrets"
|
|
tablePre1IdentityVerificationTokens = "identity_verification_tokens"
|
|
tablePre1U2FDevices = "u2f_devices"
|
|
|
|
tablePre1Config = "config"
|
|
|
|
tableAlphaAuthenticationLogs = "AuthenticationLogs"
|
|
tableAlphaIdentityVerificationTokens = "IdentityVerificationTokens"
|
|
tableAlphaPreferences = "Preferences"
|
|
tableAlphaPreferencesTableName = "PreferencesTableName"
|
|
tableAlphaSecondFactorPreferences = "SecondFactorPreferences"
|
|
tableAlphaTOTPSecrets = "TOTPSecrets"
|
|
tableAlphaU2FDeviceHandles = "U2FDeviceHandles"
|
|
)
|
|
|
|
var tablesPre1 = []string{
|
|
tablePre1TOTPSecrets,
|
|
tablePre1IdentityVerificationTokens,
|
|
tablePre1U2FDevices,
|
|
|
|
tableUserPreferences,
|
|
tableAuthenticationLogs,
|
|
}
|
|
|
|
const (
|
|
providerAll = "all"
|
|
providerMySQL = "mysql"
|
|
providerPostgres = "postgres"
|
|
providerSQLite = "sqlite"
|
|
)
|
|
|
|
const (
|
|
// This is the latest schema version for the purpose of tests.
|
|
testLatestVersion = 4
|
|
)
|
|
|
|
const (
|
|
// SchemaLatest represents the value expected for a "migrate to latest" migration. It's the maximum 32bit signed integer.
|
|
SchemaLatest = 2147483647
|
|
)
|
|
|
|
type ctxKey int
|
|
|
|
const (
|
|
ctxKeyTransaction ctxKey = iota
|
|
)
|
|
|
|
var (
|
|
reMigration = regexp.MustCompile(`^V(\d{4})\.([^.]+)\.(all|sqlite|postgres|mysql)\.(up|down)\.sql$`)
|
|
)
|