mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
remove errant encryption migration call
ensure credential migration was using the proper algorithm
This commit is contained in:
@@ -9,7 +9,6 @@ from psycopg2.extensions import AsIs
|
|||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.main.migrations import _reencrypt as reencrypt
|
|
||||||
import awx.main.fields
|
import awx.main.fields
|
||||||
from awx.main.models import Host
|
from awx.main.models import Host
|
||||||
|
|
||||||
@@ -277,7 +276,6 @@ class Migration(migrations.Migration):
|
|||||||
name='kind',
|
name='kind',
|
||||||
field=models.CharField(default=b'', help_text='Kind of inventory being represented.', max_length=32, blank=True, choices=[(b'', 'Hosts have a direct link to this inventory.'), (b'smart', 'Hosts for inventory generated using the host_filter property.')]),
|
field=models.CharField(default=b'', help_text='Kind of inventory being represented.', max_length=32, blank=True, choices=[(b'', 'Hosts have a direct link to this inventory.'), (b'smart', 'Hosts for inventory generated using the host_filter property.')]),
|
||||||
),
|
),
|
||||||
migrations.RunPython(reencrypt.replace_aesecb_fernet),
|
|
||||||
|
|
||||||
# Timeout help text update
|
# Timeout help text update
|
||||||
migrations.AlterField(
|
migrations.AlterField(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from awx.main import utils
|
from awx.main import utils
|
||||||
from awx.main.models import CredentialType
|
from awx.main.models import CredentialType
|
||||||
from awx.main.utils import encrypt_field, decrypt_field
|
from awx.conf.migrations._reencrypt import encrypt_field, decrypt_field
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,12 +26,13 @@ def _credentials(apps):
|
|||||||
Credential = apps.get_model('main', 'Credential')
|
Credential = apps.get_model('main', 'Credential')
|
||||||
for credential in Credential.objects.all():
|
for credential in Credential.objects.all():
|
||||||
for field_name, value in credential.inputs.items():
|
for field_name, value in credential.inputs.items():
|
||||||
if field_name in credential.credential_type.secret_fields:
|
if field_name in credential.credential_type.inputs.get('fields', []):
|
||||||
value = getattr(credential, field_name)
|
value = getattr(credential, field_name)
|
||||||
if value.startswith('$encrypted$AESCBC$'):
|
if value.startswith('$encrypted$AESCBC$'):
|
||||||
continue
|
continue
|
||||||
value = decrypt_field(credential, field_name)
|
elif value.startswith('$encrypted$AES$'):
|
||||||
credential.inputs[field_name] = value
|
value = decrypt_field(credential, field_name)
|
||||||
|
credential.inputs[field_name] = value
|
||||||
credential.save()
|
credential.save()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user