Spaces:
Running
Running
Deploy SmartPaper v1.1 R2.1.1Fix
#5
by GuXiaopeng - opened
- managed_auth.py +8 -2
managed_auth.py
CHANGED
|
@@ -35,11 +35,17 @@ EXECUTION_HEARTBEAT_PROOF_VERSION = "sp-execution-heartbeat-v1"
|
|
| 35 |
def _execution_heartbeat_proof(task_id: str, current_node: str) -> tuple[int, str]:
|
| 36 |
"""Create a short-lived HMAC proof that only the HF backend can mint."""
|
| 37 |
user = st.session_state.get("sp_user") or {}
|
| 38 |
-
|
| 39 |
normalized_task = str(task_id or "").strip()
|
| 40 |
normalized_node = str(current_node or "")[:240]
|
| 41 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
raise RuntimeError("execution_heartbeat_identity_required")
|
|
|
|
| 43 |
issued_at = int(time.time())
|
| 44 |
task_hash = hashlib.sha256(normalized_task.encode("utf-8")).hexdigest()
|
| 45 |
user_hash = hashlib.sha256(user_id.encode("utf-8")).hexdigest()
|
|
|
|
| 35 |
def _execution_heartbeat_proof(task_id: str, current_node: str) -> tuple[int, str]:
|
| 36 |
"""Create a short-lived HMAC proof that only the HF backend can mint."""
|
| 37 |
user = st.session_state.get("sp_user") or {}
|
| 38 |
+
numeric_id = user.get("numeric_id")
|
| 39 |
normalized_task = str(task_id or "").strip()
|
| 40 |
normalized_node = str(current_node or "")[:240]
|
| 41 |
+
if (
|
| 42 |
+
not isinstance(numeric_id, int)
|
| 43 |
+
or isinstance(numeric_id, bool)
|
| 44 |
+
or numeric_id <= 0
|
| 45 |
+
or not normalized_task
|
| 46 |
+
):
|
| 47 |
raise RuntimeError("execution_heartbeat_identity_required")
|
| 48 |
+
user_id = str(numeric_id)
|
| 49 |
issued_at = int(time.time())
|
| 50 |
task_hash = hashlib.sha256(normalized_task.encode("utf-8")).hexdigest()
|
| 51 |
user_hash = hashlib.sha256(user_id.encode("utf-8")).hexdigest()
|