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.db and ensure the users table exists.

Opens (or creates) the shared authentication database at the path defined by minimost.auth.AUTH_DB and creates the users table if it is not present. WAL journal mode is enabled for concurrent access.

Schema — ``users`` table:

Column

Type

Description

username

TEXT PK

Unique account identifier. Validated against [A-Za-z0-9_\-]{1,32} on registration.

password_hash

TEXT NOT NULL

PBKDF2 hash produced by werkzeug.security.generate_password_hash(). Never stored in plaintext.

failed_attempts

INTEGER

Count of consecutive failed login attempts since the last success. Reset to 0 on a successful login or when the account is locked.

lockout_until

REAL

Unix timestamp until which logins are rejected, or NULL when the account is not locked. Set once failed_attempts reaches the configured threshold. See minimost.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

username

TEXT PK

Unique account identifier. Validated against [A-Za-z0-9_\\-]{1,32} on registration.

password_hash

TEXT NOT NULL

PBKDF2 hash produced by Werkzeug. Never stored in plaintext.