Ensure that photo verification data is correctly typed.

There were cases where we needed to encode things to codecs other than
ascii.  In these cases, python returns byte strings but we needed them
to be unicode so that they serialize correctly later when we combine
them with other unicode strings.
This commit is contained in:
Feanil Patel
2019-12-18 13:54:37 -05:00
parent 597c5d5f15
commit 3808b2991c
3 changed files with 3 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ class Command(BaseCommand):
dest='verification_ids',
action='store',
nargs='+',
type=int,
type=str,
help='verifications id used to retry verification'
)

View File

@@ -837,7 +837,7 @@ class SoftwareSecurePhotoVerification(PhotoVerification):
face_aes_key = codecs.decode(face_aes_key_str, 'hex')
rsa_key_str = settings.VERIFY_STUDENT["SOFTWARE_SECURE"]["RSA_PUBLIC_KEY"]
rsa_encrypted_face_aes_key = rsa_encrypt(face_aes_key, rsa_key_str)
return base64.b64encode(rsa_encrypted_face_aes_key)
return base64.b64encode(rsa_encrypted_face_aes_key).decode('utf-8')
def create_request(self, copy_id_photo_from=None):
"""

View File

@@ -176,7 +176,7 @@ def generate_signed_message(method, headers_dict, body_dict, access_key, secret_
# hmac needs a byte string for it's starting key, can't be unicode.
hashed = hmac.new(secret_key.encode('utf-8'), message.encode('utf-8'), sha256)
signature = binascii.b2a_base64(hashed.digest()).rstrip(b'\n')
signature = binascii.b2a_base64(hashed.digest()).rstrip(b'\n').decode('utf-8')
authorization_header = u"SSI {}:{}".format(access_key, signature)
message += '\n'