Skip to content

Commit

Permalink
Python 3.x compatible!
Browse files Browse the repository at this point in the history
  • Loading branch information
adcreare committed Jun 28, 2019
1 parent 1c34a19 commit aa4ab76
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions aws_google_auth/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def find_key_handle(input, challengeTxt):
typeOfInput = type(input)
if typeOfInput == dict: # parse down a dict
for item in input:
return Google.find_key_handle(input[item], challengeTxt)
rvalue = Google.find_key_handle(input[item], challengeTxt)
if rvalue is not None:
return rvalue

elif typeOfInput == list: # looks like we've hit an array - iterate it
array = list(filter(None, input)) # remove any None type objects from the array
for item in array:
Expand Down Expand Up @@ -408,9 +411,10 @@ def handle_sk(self, sess):

# txt sent for signing needs to be base64 url encode
# we also have to remove any base64 padding because including including it will prevent google accepting the auth response
challenges_txt_encode_pad_removed = base64.urlsafe_b64encode(base64.b64decode(challenges_txt)).strip('=')
challenges_txt_encode_pad_removed = base64.urlsafe_b64encode(base64.b64decode(challenges_txt)).strip('='.encode())

u2f_challenges = []
u2f_challenges.append({'version': 'U2F_V2', 'challenge': challenges_txt_encode_pad_removed, 'appId': appId, 'keyHandle': keyHandle})
u2f_challenges.append({'version': 'U2F_V2', 'challenge': challenges_txt_encode_pad_removed.decode(), 'appId': appId, 'keyHandle': keyHandle.decode()})

# Prompt the user up to attempts_remaining times to insert their U2F device.
attempts_remaining = 5
Expand Down

0 comments on commit aa4ab76

Please sign in to comment.