1
0

Password-protect the JSON RPC interface

This commit is contained in:
SomberNight
2018-01-07 19:26:59 +01:00
parent f8fad2fd29
commit af527b21fb
3 changed files with 137 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ from decimal import Decimal
import traceback
import urllib
import threading
import hmac
from .i18n import _
@@ -202,6 +203,13 @@ def json_decode(x):
except:
return x
# taken from Django Source Code
def constant_time_compare(val1, val2):
"""Return True if the two strings are equal, False otherwise."""
return hmac.compare_digest(to_bytes(val1, 'utf8'), to_bytes(val2, 'utf8'))
# decorator that prints execution time
def profiler(func):
def do_profile(func, args, kw_args):