Spaces:
Paused
Paused
Upload core/csrf.py with huggingface_hub
Browse files- core/csrf.py +3 -1
core/csrf.py
CHANGED
|
@@ -32,7 +32,9 @@ class CSRFProtection:
|
|
| 32 |
|
| 33 |
# Recreate signature
|
| 34 |
message = f"{session_id}:{nonce}".encode()
|
| 35 |
-
expected_signature = hmac.new(
|
|
|
|
|
|
|
| 36 |
|
| 37 |
# Constant-time comparison
|
| 38 |
return hmac.compare_digest(signature, expected_signature)
|
|
|
|
| 32 |
|
| 33 |
# Recreate signature
|
| 34 |
message = f"{session_id}:{nonce}".encode()
|
| 35 |
+
expected_signature = hmac.new(
|
| 36 |
+
self.secret_key, message, hashlib.sha256
|
| 37 |
+
).hexdigest()
|
| 38 |
|
| 39 |
# Constant-time comparison
|
| 40 |
return hmac.compare_digest(signature, expected_signature)
|