Skip to content

Database Schema

Autentico uses a single SQLite database file. All tables are created on startup if they don’t exist. Schema migrations are applied automatically via ALTER TABLE … ADD COLUMN (idempotent).

Stores all user accounts.

ColumnTypeNotes
idTEXT PKUUID — the sub claim in tokens
usernameTEXT UNIQUELogin name
emailTEXT UNIQUEOptional; enforced unique if set
passwordTEXTbcrypt hash
roleTEXTuser or admin
totp_secretTEXTbase32-encoded TOTP shared secret
totp_verifiedBOOLEANWhether enrollment is complete
failed_login_attemptsINTEGERResets on successful login
locked_untilDATETIMENULL = not locked
is_email_verifiedBOOLEAN
deactivated_atDATETIMENULL = active
created_atDATETIME

Registered OAuth2 clients.

ColumnTypeNotes
idTEXT PKInternal UUID
client_idTEXT UNIQUEPublic identifier
client_secretTEXTNULL for public clients
client_nameTEXT
client_typeTEXTconfidential or public
redirect_urisTEXTJSON array
grant_typesTEXTJSON array
response_typesTEXTJSON array
scopesTEXTSpace-separated
token_endpoint_auth_methodTEXT
is_activeBOOLEAN
access_token_expirationTEXTNULL = use global
refresh_token_expirationTEXTNULL = use global
authorization_code_expirationTEXTNULL = use global
allowed_audiencesTEXTJSON array or NULL
allow_self_signupINTEGERNULL = use global
sso_session_idle_timeoutTEXTNULL = use global
trust_device_enabledINTEGERNULL = use global
trust_device_expirationTEXTNULL = use global

Issued access and refresh token records.

ColumnTypeNotes
idTEXT PK
user_idTEXT FK→ users
access_tokenTEXTJWT
refresh_tokenTEXTJWT
access_token_typeTEXTBearer
access_token_expires_atDATETIME
refresh_token_expires_atDATETIME
scopeTEXT
grant_typeTEXT
revoked_atDATETIMENULL = not revoked

SSO sessions (browser-facing, managed by session cookie).

ColumnTypeNotes
idTEXT PKStored in browser cookie
user_idTEXT FK→ users
user_agentTEXT
ip_addressTEXT
last_activity_atDATETIMEUpdated on each auto-login
created_atDATETIME
deactivated_atDATETIMENULL = active

Short-lived authorization codes (typically 1-5 min).

ColumnTypeNotes
codeTEXT PK
user_idTEXT FK→ users
client_idTEXT
redirect_uriTEXT
scopeTEXT
nonceTEXTOIDC replay protection
code_challengeTEXTPKCE
code_challenge_methodTEXTS256 or plain
expires_atDATETIME
usedBOOLEANSingle-use

Pending MFA challenges (TOTP or email OTP).

ColumnNotes
idChallenge token — included in redirect URL
user_id
methodtotp or email
codeOTP code (email OTP only)
login_stateJSON blob with OAuth params to resume after MFA
expires_at5 minutes
usedSingle-use

Trusted device records for MFA bypass.

ColumnNotes
idToken stored in browser cookie
user_id
device_nameUser-agent at trust time
last_used_at
expires_atConfigurable via trust_device_expiration

Pending WebAuthn authentication or registration challenges.

ColumnNotes
idChallenge ID returned to the browser
user_id
challenge_dataJSON SessionData from go-webauthn
typeauthentication or registration
login_stateJSON OAuth params to resume after passkey
expires_at5 minutes
usedSingle-use

Registered WebAuthn credentials.

ColumnNotes
idCredential ID (from WebAuthn)
user_id
nameOptional user-visible name
credentialJSON blob (full Credential from go-webauthn)
last_used_at

Key-value store for runtime settings.

ColumnNotes
keySetting name (e.g. mfa_enabled)
valueString value
updated_at