Create admin/auth.py
Browse files- admin/auth.py +11 -0
admin/auth.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
log = logging.getLogger("admin.auth")
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def check_admin_password(supplied: str, expected: str) -> bool:
|
| 7 |
+
if not supplied or not expected:
|
| 8 |
+
return False
|
| 9 |
+
# constant-time compare
|
| 10 |
+
import hmac
|
| 11 |
+
return hmac.compare_digest(supplied, expected)
|