From 109db14817c2c580e443ddc6302a120ecf46eb60 Mon Sep 17 00:00:00 2001 From: Shine1i Date: Mon, 9 Mar 2026 20:15:10 +0100 Subject: [PATCH] feat(studio): add auth-specific paths and integrate auth database location --- studio/backend/auth/storage.py | 7 ++++--- studio/backend/utils/paths/__init__.py | 4 ++++ studio/backend/utils/paths/storage_roots.py | 8 ++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/studio/backend/auth/storage.py b/studio/backend/auth/storage.py index f72a7ed943..cb5df6e3f9 100644 --- a/studio/backend/auth/storage.py +++ b/studio/backend/auth/storage.py @@ -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() - diff --git a/studio/backend/utils/paths/__init__.py b/studio/backend/utils/paths/__init__.py index 307f630a29..b13d949924 100644 --- a/studio/backend/utils/paths/__init__.py +++ b/studio/backend/utils/paths/__init__.py @@ -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', diff --git a/studio/backend/utils/paths/storage_roots.py b/studio/backend/utils/paths/storage_roots.py index 58d2af16c1..a005d604a8 100644 --- a/studio/backend/utils/paths/storage_roots.py +++ b/studio/backend/utils/paths/storage_roots.py @@ -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"