Spaces:
Running
Running
Match Studio HMAC canonicalization
Browse filesUse the exact newline-separated envelope format produced by the Studio proxy.
app/security/studio_identity.py
CHANGED
|
@@ -56,7 +56,7 @@ def verify_studio_identity(
|
|
| 56 |
current = time.time() if now is None else now
|
| 57 |
if abs(current - timestamp) > max_age_seconds:
|
| 58 |
raise ValueError("Studio identity envelope has expired.")
|
| 59 |
-
canonical = "\
|
| 60 |
expected = hmac.digest(secret.encode("utf-8"), canonical, "sha256").hex()
|
| 61 |
if not hmac.compare_digest(expected, signature):
|
| 62 |
raise ValueError("Studio identity signature is invalid.")
|
|
|
|
| 56 |
current = time.time() if now is None else now
|
| 57 |
if abs(current - timestamp) > max_age_seconds:
|
| 58 |
raise ValueError("Studio identity envelope has expired.")
|
| 59 |
+
canonical = "\n".join((timestamp_text, subject, email, name)).encode("utf-8")
|
| 60 |
expected = hmac.digest(secret.encode("utf-8"), canonical, "sha256").hex()
|
| 61 |
if not hmac.compare_digest(expected, signature):
|
| 62 |
raise ValueError("Studio identity signature is invalid.")
|