Gitlab CSE Unil

Commit 1b6183ff authored by M. Chardon's avatar M. Chardon
Browse files

maj lien moodle

parent 263244c7
......@@ -24,6 +24,24 @@ DATABASES = {
},
}
ATTP = {
'OPTIONS': {
'CACHE_TIMEOUT': 20, # 30,
},
'moodle': {
'CHECK_URL': "http://localhost/moodle35riset/moodle35/mod/adim/checkAccess.php?uuid={uuid}",
'MODE_ID': 16
},
'toto': {
'CHECK_URL': "http://localhost/tests/phpupload/toto.php?a={uuid}",
'MODE_ID': 24
},
'my_ttp': {
'CHECK_URL': "http://my-ttp:8001/ttp/check/{uuid}/",
'MODE_ID': 32
}
}
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_FILE_PATH = '{}/log/emails/current'.format(dirname(SITE_ROOT))
......
......@@ -63,9 +63,10 @@ def get_attp_message(attp_msg64, attp_hash):
# Check hash validity
attp_salt = msg.get('salt', '')
key ='{salt}{time}{key}'.format(salt=attp_salt, time=attp_time, key=settings.ATTP_KEYS.get(attp_id))
ctrl_hmac = hmac.new(
"{salt}{time}{key}".format(salt=attp_salt, time=attp_time, key=settings.ATTP_KEYS.get(attp_id)),
attp_msg64, sha256
bytes(key, 'utf-8'),
bytes(attp_msg64, 'utf-8'), sha256
)
if attp_hash != ctrl_hmac.hexdigest():
# Invalid message control
......@@ -87,6 +88,7 @@ def get_request_attp(request):
:param request:
:return:
"""
attp_msg64 = request.META.get('HTTP_X_ATTP_MSG')
attp_hash = request.META.get('HTTP_X_ATTP_H')
if not attp_msg64:
......
......@@ -36,7 +36,10 @@ def cache(seconds=300):
def clear_function_cache(f, *args, **kwargs):
f_str = str(f.__module__) + str(f.__name__) if callable(f) else f
try:
key = sha1(f_str + str(args) + str(kwargs)).hexdigest()
clearKey = f_str + str(args) + str(kwargs)
clearKeyEncode = clearKey.encode('utf-8')
key = sha1(clearKeyEncode).hexdigest()
# key = sha1(f_str + str(args) + str(kwargs)).hexdigest()
except UnicodeDecodeError:
key = ""
_djcache.delete(key)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment