Self-hosted AI workspace.
Python
fix(auth): add config lock around migration methods (#4447)
Side2edb4bfaecd
diff --git a/core/auth.py b/core/auth.pyindex 3bdf0f390..4bc9a70dd 100644--- a/core/auth.py+++ b/core/auth.py@@ -176,16 +176,17 @@ class AuthManager:)old_user = "admin"old_hash = self._config["password_hash"]- self._config = {- "users": {- old_user: {- "password_hash": old_hash,- "created": time.time(),- "is_admin": True,+ with self._config_lock:+ self._config = {+ "users": {+ old_user: {+ "password_hash": old_hash,+ "created": time.time(),+ "is_admin": True,+ }}}- }- self._save()+ self._save()logger.info(f"Migrated single-user auth to multi-user (admin: {old_user})")def _drop_reserved_loaded_users(self):@@ -204,8 +205,9 @@ class AuthManager:continuenormalized[key] = dataif removed or normalized != users:- self._config["users"] = normalized- self._save()+ with self._config_lock:+ self._config["users"] = normalized+ self._save()if removed:logger.warning("Removed reserved username(s) from auth config: %s",