minimost.database
minimost.database
Authentication database schema initialisation.
This module bootstraps the shared auth.db SQLite database, which stores
all user credentials. It is imported — and therefore executed — by
minimost.create_app() as a side effect of the import chain.
Why a separate module?
Keeping schema initialisation in its own module avoids circular imports: both
minimost.auth (which defines AUTH_DB) and higher-level modules need
to reference the same initialisation step, and a dedicated module is the
cleanest boundary.
Side effect at import time:
init_auth_db() is called unconditionally at module level when this
module is first imported. This guarantees that auth.db exists and has the
correct schema before any authentication route is reached.
- minimost.database.init_auth_db()[source]
Create
auth.dband ensure theuserstable exists.Opens (or creates) the shared authentication database at the path defined by
minimost.auth.AUTH_DBand creates theuserstable if it is not present. WAL journal mode is enabled for concurrent access.Schema — ``users`` table:
Column
Type
Description
usernameTEXT PK
Unique account identifier. Validated against
[A-Za-z0-9_\-]{1,32}on registration.password_hashTEXT NOT NULL
PBKDF2 hash produced by
werkzeug.security.generate_password_hash(). Never stored in plaintext.failed_attemptsINTEGER
Count of consecutive failed login attempts since the last success. Reset to
0on a successful login or when the account is locked.lockout_untilREAL
Unix timestamp until which logins are rejected, or
NULLwhen the account is not locked. Set oncefailed_attemptsreaches the configured threshold. Seeminimost.auth.login_post().This function is idempotent — safe to call multiple times.
- Returns:
None
Note
minimost.database.init_auth_db() is called automatically at module
import time. It is not necessary to call it manually.
auth.db Schema
Column |
Type |
Description |
|---|---|---|
|
TEXT PK |
Unique account identifier. Validated against
|
|
TEXT NOT NULL |
PBKDF2 hash produced by Werkzeug. Never stored in plaintext. |