mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Put the utf8 encoding in the right place for the cipher
This commit is contained in:
parent
4eb323caa4
commit
e16e5a0dfa
@ -350,7 +350,7 @@ class Credential(CommonModelNameNotUnique):
|
||||
# if hit hasn't been specified, then we're just doing a normal save.
|
||||
for field in self.PASSWORD_FIELDS:
|
||||
ask = bool(self.kind == 'ssh' and field != 'ssh_key_data')
|
||||
encrypted = encrypt_field(self, field, ask.encode('utf-8'))
|
||||
encrypted = encrypt_field(self, field, ask)
|
||||
setattr(self, field, encrypted)
|
||||
if field not in update_fields:
|
||||
update_fields.append(field)
|
||||
|
@ -104,6 +104,7 @@ def encrypt_field(instance, field_name, ask=False):
|
||||
value = getattr(instance, field_name)
|
||||
if not value or value.startswith('$encrypted$') or (ask and value == 'ASK'):
|
||||
return value
|
||||
value = value.encode('utf-8')
|
||||
key = get_encryption_key(instance, field_name)
|
||||
cipher = AES.new(key, AES.MODE_ECB)
|
||||
while len(value) % cipher.block_size != 0:
|
||||
|
Loading…
Reference in New Issue
Block a user