mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 03:47:36 -02:30
Accept and convert SSH creds ending in \u003d.
This commit fixes an issue where copying an SSH credential ending in a literal "\u003d", which is easy to do in GCE-land, doesn't work. https://trello.com/c/L7Eowjrn/331-traceback-on-gce-inventory-import
This commit is contained in:
@@ -283,6 +283,19 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
|
|||||||
else:
|
else:
|
||||||
ssh_key_data = self.ssh_key_data
|
ssh_key_data = self.ssh_key_data
|
||||||
if ssh_key_data:
|
if ssh_key_data:
|
||||||
|
# Sanity check: GCE, in particular, provides JSON-encoded private
|
||||||
|
# keys, which developers will be tempted to copy and paste rather
|
||||||
|
# than JSON decode.
|
||||||
|
#
|
||||||
|
# These end in a unicode-encoded final character that gets double
|
||||||
|
# escaped due to being in a Python 2 bytestring, and that causes
|
||||||
|
# Python's key parsing to barf. Detect this issue and correct it.
|
||||||
|
if r'\u003d' in ssh_key_data:
|
||||||
|
ssh_key_data = ssh_key_data.replace(r'\u003d', '=')
|
||||||
|
self.ssh_key_data = ssh_key_data
|
||||||
|
|
||||||
|
# Validate the private key to ensure that it looks like something
|
||||||
|
# that we can accept.
|
||||||
self._validate_ssh_private_key(ssh_key_data)
|
self._validate_ssh_private_key(ssh_key_data)
|
||||||
return self.ssh_key_data # No need to return decrypted version here.
|
return self.ssh_key_data # No need to return decrypted version here.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user