|
|
@@ -3,7 +3,6 @@ Device registration endpoint.
|
|
|
"""
|
|
|
|
|
|
import asyncio
|
|
|
-import copy
|
|
|
import json
|
|
|
import secrets
|
|
|
from base64 import b64encode
|
|
|
@@ -23,10 +22,14 @@ from app.utils.ssh_keys import sync_authorized_keys
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
-# Load default config from JSON file
|
|
|
+# Path to default config file
|
|
|
DEFAULT_CONFIG_PATH = Path(__file__).parent.parent.parent / "default_config.json"
|
|
|
-with open(DEFAULT_CONFIG_PATH, "r") as f:
|
|
|
- DEFAULT_CONFIG = json.load(f)
|
|
|
+
|
|
|
+
|
|
|
+def _load_default_config() -> dict:
|
|
|
+ """Load default config from file (not cached, always fresh)."""
|
|
|
+ with open(DEFAULT_CONFIG_PATH, "r") as f:
|
|
|
+ return json.load(f)
|
|
|
|
|
|
|
|
|
class RegistrationRequest(BaseModel):
|
|
|
@@ -118,9 +121,8 @@ async def register_device(
|
|
|
detail="Registration disabled. Contact administrator.",
|
|
|
)
|
|
|
|
|
|
- # Create new device with default config
|
|
|
- # Deep copy to avoid modifying the global default
|
|
|
- device_config = copy.deepcopy(DEFAULT_CONFIG)
|
|
|
+ # Create new device with default config (read fresh from file)
|
|
|
+ device_config = _load_default_config()
|
|
|
|
|
|
# Add SSH public key if provided
|
|
|
if data.ssh_public_key:
|