Skip to content

Commit 91c5549

Browse files
committed
Merge branch '242' into 'main'
Use HMAC to build hashes See merge request yaal/canaille!246
2 parents 48cc12d + 5cdf952 commit 91c5549

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

canaille/app/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import base64
22
import hashlib
3+
import hmac
34
import json
45
import re
56
from base64 import b64encode
@@ -20,10 +21,9 @@ def b64_to_obj(string):
2021

2122

2223
def build_hash(*args):
23-
return hashlib.sha256(
24-
current_app.config["SECRET_KEY"].encode("utf-8")
25-
+ obj_to_b64(str(args)).encode("utf-8")
26-
).hexdigest()
24+
key = current_app.config["SECRET_KEY"].encode("utf-8")
25+
message = obj_to_b64(str(args)).encode("utf-8")
26+
return hmac.new(key, message, hashlib.sha256).hexdigest()
2727

2828

2929
def default_fields():

0 commit comments

Comments
 (0)