diff options
author | Aravinda VK <avishwan@redhat.com> | 2018-04-18 15:08:55 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-04-20 05:09:17 +0000 |
commit | ef8f9ad76a5a1c9495a77e7e83b7fd05a9a7e757 (patch) | |
tree | 4ba002191b6d13ff03c5502fecd0a5763b9f8c0e | |
parent | 9e7082b756058fe04d79c046fbd6dcbfa75a1716 (diff) |
eventsapi: Handle Unicode string during signing
Python 2.7 HMAC does not support Unicode strings. Secret is read
from file so it is possible that glustereventsd reads the content
as Unicode. This patch converts the secret to `str` type before
generating HMAC signature.
Fixes: bz#1568820
Change-Id: I7daa64499ac4ca02544405af26ac8af4b6b0bd95
Signed-off-by: Aravinda VK <avishwan@redhat.com>
-rw-r--r-- | events/src/utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/events/src/utils.py b/events/src/utils.py index f405e44ac70..7d9b7b51d95 100644 --- a/events/src/utils.py +++ b/events/src/utils.py @@ -206,7 +206,7 @@ def get_jwt_token(secret, event_type, event_ts, jwt_expiry_time_seconds=60): msg = base64_urlencode(header) + "." + base64_urlencode(payload) return "%s.%s" % ( msg, - base64_urlencode(hmac.HMAC(secret, msg, sha256).digest()) + base64_urlencode(hmac.HMAC(str(secret), msg, sha256).digest()) ) |