You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to see a patch for this issue. Let's say you are including warrant-lite in GUI application made in PyGTK or PyQT, in such case locale will be get overriden by system-wide locale.
Quick fix would be a class which inherits the WarrantLite, i.e.:
importbase64importdatetimeimporthashlibimporthmacimportlocaleimportrefromwarrant_liteimportWarrantLite, hex_to_longclassWarrantModified(WarrantLite):
defprocess_challenge(self, challenge_parameters):
user_id_for_srp=challenge_parameters['USER_ID_FOR_SRP']
salt_hex=challenge_parameters['SALT']
srp_b_hex=challenge_parameters['SRP_B']
secret_block_b64=challenge_parameters['SECRET_BLOCK']
# re strips leading zero from a day number (required by AWS Cognito)# NOTE: Specify en_US localelocale.setlocale(locale.LC_ALL, ('en_US', 'UTF-8'))
timestamp=re.sub(r" 0(\d) ", r" \1 ",
datetime.datetime.utcnow().strftime("%a %b %d %H:%M:%S UTC %Y"))
# NOTE: Return to default localelocale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
hkdf=self.get_password_authentication_key(user_id_for_srp,
self.password, hex_to_long(srp_b_hex), salt_hex)
secret_block_bytes=base64.standard_b64decode(secret_block_b64)
msg=bytearray(self.pool_id.split('_')[1], 'utf-8') +bytearray(user_id_for_srp, 'utf-8') + \
bytearray(secret_block_bytes) +bytearray(timestamp, 'utf-8')
hmac_obj=hmac.new(hkdf, msg, digestmod=hashlib.sha256)
signature_string=base64.standard_b64encode(hmac_obj.digest())
response= {'TIMESTAMP': timestamp,
'USERNAME': user_id_for_srp,
'PASSWORD_CLAIM_SECRET_BLOCK': secret_block_b64,
'PASSWORD_CLAIM_SIGNATURE': signature_string.decode('utf-8')}
ifself.client_secretisnotNone:
response.update({
"SECRET_HASH":
self.get_secret_hash(self.username, self.client_id, self.client_secret)})
returnresponse
In https://github.com/capless/warrant-lite/blob/master/warrant_lite/__init__.py#L193, if the LOCALE is not set to English, this would fail.
The text was updated successfully, but these errors were encountered: