MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _init_auth_db

Method _init_auth_db

auth_manager.py:78–110  ·  view source on GitHub ↗

Create the auth database schema if it doesn't exist.

(self)

Source from the content-addressed store, hash-verified

76 # =========================================================================
77
78 def _init_auth_db(self):
79 """Create the auth database schema if it doesn't exist."""
80 with self._get_auth_conn() as conn:
81 cursor = conn.cursor()
82 cursor.execute("""
83 CREATE TABLE IF NOT EXISTS auth (
84 id INTEGER PRIMARY KEY,
85 username TEXT NOT NULL,
86 password_hash TEXT NOT NULL,
87 password_salt TEXT NOT NULL,
88 hardware_fingerprint TEXT NOT NULL,
89 encrypted_fernet_key TEXT NOT NULL,
90 created_at TEXT DEFAULT CURRENT_TIMESTAMP,
91 updated_at TEXT DEFAULT CURRENT_TIMESTAMP
92 )
93 """)
94 cursor.execute("""
95 CREATE TABLE IF NOT EXISTS recovery_codes (
96 id INTEGER PRIMARY KEY,
97 code_hash TEXT NOT NULL,
98 code_salt TEXT NOT NULL,
99 encrypted_fernet_key TEXT NOT NULL,
100 used INTEGER DEFAULT 0,
101 used_at TEXT DEFAULT NULL
102 )
103 """)
104 cursor.execute("""
105 CREATE TABLE IF NOT EXISTS app_secrets (
106 key TEXT PRIMARY KEY,
107 value TEXT NOT NULL
108 )
109 """)
110 conn.commit()
111
112 @contextmanager
113 def _get_auth_conn(self):

Callers 2

__init__Method · 0.95
is_configuredMethod · 0.95

Calls 4

_get_auth_connMethod · 0.95
cursorMethod · 0.80
commitMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected