e7a346
From 10fa7c3ad785c0da0d1981b40470149e23cb4acc Mon Sep 17 00:00:00 2001
e7a346
From: Aravinda VK <avishwan@redhat.com>
e7a346
Date: Wed, 18 Apr 2018 15:08:55 +0530
e7a346
Subject: [PATCH 232/236] eventsapi: Handle Unicode string during signing
e7a346
e7a346
Python 2.7 HMAC does not support Unicode strings. Secret is read
e7a346
from file so it is possible that glustereventsd reads the content
e7a346
as Unicode. This patch converts the secret to `str` type before
e7a346
generating HMAC signature.
e7a346
e7a346
>Fixes: bz#1568820
e7a346
>Change-Id: I7daa64499ac4ca02544405af26ac8af4b6b0bd95
e7a346
>Signed-off-by: Aravinda VK <avishwan@redhat.com>
e7a346
e7a346
Upstream Patch: https://review.gluster.org/#/c/19900/
e7a346
e7a346
BUG: 1466129
e7a346
Change-Id: I7daa64499ac4ca02544405af26ac8af4b6b0bd95
e7a346
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/136327
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
e7a346
---
e7a346
 events/src/utils.py | 2 +-
e7a346
 1 file changed, 1 insertion(+), 1 deletion(-)
e7a346
e7a346
diff --git a/events/src/utils.py b/events/src/utils.py
e7a346
index f405e44..7d9b7b5 100644
e7a346
--- a/events/src/utils.py
e7a346
+++ b/events/src/utils.py
e7a346
@@ -206,7 +206,7 @@ def get_jwt_token(secret, event_type, event_ts, jwt_expiry_time_seconds=60):
e7a346
     msg = base64_urlencode(header) + "." + base64_urlencode(payload)
e7a346
     return "%s.%s" % (
e7a346
         msg,
e7a346
-        base64_urlencode(hmac.HMAC(secret, msg, sha256).digest())
e7a346
+        base64_urlencode(hmac.HMAC(str(secret), msg, sha256).digest())
e7a346
     )
e7a346
 
e7a346
 
e7a346
-- 
e7a346
1.8.3.1
e7a346