feat(studio): add auth-specific paths and integrate auth database location
This commit is contained in:
parent
958bdef43e
commit
109db14817
3 changed files with 16 additions and 3 deletions
|
|
@ -7,10 +7,11 @@ SQLite storage for authentication data (user credentials + JWT secret).
|
|||
import hashlib
|
||||
import sqlite3
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Optional, Tuple
|
||||
|
||||
DB_PATH = Path(__file__).parent / "auth.db"
|
||||
from utils.paths import auth_db_path, ensure_dir
|
||||
|
||||
DB_PATH = auth_db_path()
|
||||
|
||||
|
||||
def _hash_token(token: str) -> str:
|
||||
|
|
@ -20,6 +21,7 @@ def _hash_token(token: str) -> str:
|
|||
|
||||
def get_connection() -> sqlite3.Connection:
|
||||
"""Get a connection to the auth database, creating tables if needed."""
|
||||
ensure_dir(DB_PATH.parent)
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
conn.row_factory = sqlite3.Row
|
||||
conn.execute(
|
||||
|
|
@ -256,4 +258,3 @@ def revoke_user_refresh_tokens(username: str) -> None:
|
|||
conn.commit()
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ from .storage_roots import (
|
|||
recipe_datasets_root,
|
||||
outputs_root,
|
||||
exports_root,
|
||||
auth_root,
|
||||
auth_db_path,
|
||||
tmp_root,
|
||||
seed_uploads_root,
|
||||
unstructured_seed_cache_root,
|
||||
|
|
@ -38,6 +40,8 @@ __all__ = [
|
|||
'recipe_datasets_root',
|
||||
'outputs_root',
|
||||
'exports_root',
|
||||
'auth_root',
|
||||
'auth_db_path',
|
||||
'tmp_root',
|
||||
'seed_uploads_root',
|
||||
'unstructured_seed_cache_root',
|
||||
|
|
|
|||
|
|
@ -32,6 +32,14 @@ def exports_root() -> Path:
|
|||
return studio_root() / "exports"
|
||||
|
||||
|
||||
def auth_root() -> Path:
|
||||
return studio_root() / "auth"
|
||||
|
||||
|
||||
def auth_db_path() -> Path:
|
||||
return auth_root() / "auth.db"
|
||||
|
||||
|
||||
def tmp_root() -> Path:
|
||||
return Path(tempfile.gettempdir()) / "unsloth-studio"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue